The Hickensian

31.05.06 Web Development with... Safari

When it comes to testing and debugging sites, it seems that Firefox can’t be beaten. Not only does it have an inbuilt DOM Inspector and Javascript console to beat all others, but the plethora of useful extensions is unmatched. Everyone knows and uses Chris Pedericks Web Developer extension, along with any number other handy extras – Firebug, X-Ray, Aardvark, etc.

Other browsers have useful tools though, which gave me an idea for an ad-hoc series highlighting useful web development features, starting with Safari. While it doesn’t have an official plugin architecture like Firefox, that hasn’t stopped developers finding ways around it and providing excellent plugins.

The Web Inspector

(More Information)

The first one isn’t a plugin at all, the Web Inspector is a ‘future feature’ of Safari, available in the WebKit nightly builds. Until this becomes the mainstream release, you have to download a webkit nightly from here.

Once you’ve coped WebKit.app over to your applications folder, open terminal.app and type:

defaults write com.apple.Safari WebKitDeveloperExtras -bool true

Web Inspector context menu command

Then when you launch WebKit.app instead of Safari the context menu has the command ‘inspect element’ at the bottom. Selecting this will show the inspector. Like the Mozilla DOM Inspector, it will show you source and style information for any element, but in an Aperture style ‘HUD’ window.

Web Inspector window

If you want to keep your copy of WebKit up to date, you can use NightShift to automate the process for you.

SafariStand

(More Information)

SafariStand's action menu

SafariStand adds an ‘action menu’ button to your toolbar options. Its not there by default – you have to customise the toolbar to add it. Once added, you can use the useful ‘Sub Resources’ menu, which lists all the linked assets from the page – css, javascript, gifs, swfs, etc. Select one, and it opens in a new window.

‘Show Page Info’ option which displays this date again, but more like Firefox’s page info window.

SafariStand page info window

‘Show Related cookies’ shows you all cookies from the current site, with options to delete them.

You can also use SafariStand to colour your view source, but I recommend SafariSource for that (see below). Do tick the option of Source > Editable though, as this will allow you to make changes to the HTML and redisplay it, a great feature for debugging.

SafariTidy

(More Information)

Safaritidy status bar messageA newcomer is this tasty little free plugin. At the time of writing its only on version 0.2, but already adds many useful web development features.

It sits in the status bar, telling you of validation warnings and errors, and when clicked, displays the source view along with a clickable list of message in a split view beneath. It also adds line numbers to the source (joy!!). The plugin has been designed to work with SafariSource, and I have run both with no problems.

SafariTidy source view

The screenshot above shows SafariStands editable source tools (top toolbar), SafariSource’s syntax colouring and SafariTidy’s line numbers and warnings list.

SafariSource

(More Information)

This wee plugin gives you more options for colouring the source view. While SafariStand does have syntax colouring options, SafariSource allows you to be far more prescriptive about it.

SafariSource preferences

It requires SIMBL to be installed first.

Also…

One plugin I haven’t included is WebDevAdditions, which adds many useful commands to the View menu. I haven’t heard of any updates to this in a while, and I used to get problems using it in conjunction with other plugins, so I haven’t gone into any depth with it here. By all means, try it out and see if it works for you.

There are many more plugins for Safari of course, these are just the ones that aid web development. As always, you can find out about more plugins for Safari at PimpMySafari, where there is also a good list of webdev bookmarklets that have been tested for Safari.

Comments | RSS

No.1

Colly said 1350 days ago:

Lovely. As you know Jon, I’m using Safari as my default once more, seeing as Firefox is on a go-slow. SafariStand is excellent – and thanks for the Action Menu tip. That’s a nice hidden gem.

No.2

Eystein said 1350 days ago:

This’s great! Lately I’ve completly abounded Safari because of Firefox’ many great extensions. I’ll give this a testdrive.

No.3

Joost de Valk said 1350 days ago:

Hi Jon,

thx for the great article, and for helping people know about WebKit :)

Joost

No.4

Mark Rowe said 1350 days ago:

Jon, the WebKit nightly builds enable the DOM Inspector automatically, so it is not necessary to do the _ defaults write com.apple.Safari WebKitDeveloperExtras -bool true_ as you describe. There is no harm in doing so, but no benefit either.

No.5

Steve Tucker said 1350 days ago:

Didnt realise Safari had so much developer flexibility.The nail in the coffin of other browsers for me was the discovery of the developer extension toolbar onto FireFox. I still dont think it can be beaten.

No.6

Ramin said 1350 days ago:

yeah me too. i’m actually pretty sneaky, with firefox i like to fire up the web developer css editor on other peoples sites have a good read and mess with their code.

i’ve actually learned a lot from doing that.

No.7

Jon Hicks said 1350 days ago:

“the developer extension toolbar onto FireFox. I still dont think it can be beaten.”

OK, thats the last time anyone needs to say that. Lets just take it as read that you all like that extension! ;o)

No.8

Gareth Houston said 1350 days ago:

Nice informative article once again Jon . I too have been using Firefox with the web developer toolbar plug-in, which has been a vital asset to my work. Although the Firefox plug-in has never let me down I do think it’s about time to test a few other options and see what the others have to offer. After reading this article I am defiantly going to give the WebKit plug-in a go.

Thanks again :)

No.9

Ryan Irelan said 1350 days ago:

There is one inbuilt feature of Safari that I find is one of the most valuable tools when building a website:

Activity Window
(Window > Activity or Option-Command-A).’

No.10

matt said 1350 days ago:

I think Xyle Scope is a good alternative to Webkit’s Inspector beta and is in some ways better.

No.11

Hrvoje said 1350 days ago:

When you press ctrl+shift and click on a page – you get in the pop-up menu the DOM reference of the element, and by selecting it you can paste it in your javascript code.

No.12

Jon Hicks said 1350 days ago:

“When you press ctrl+shift and click on a page – you get in the pop-up menu the DOM reference of the element, and by selecting it you can paste it in your javascript code.”

Hmm, I don’t. Is this some new plugin?

No.13

Henning said 1350 days ago:

@Hrvoje

This is part of the above mentioned WebDevAdditions. I haven’t noticed it before either, but this behaviour is even described on their site:

“”document.getElementsByTagName(“IMG”)[16] is a valid javascript reference to a pointed object. It is ready to paste into your script (directly from the clipboard). Second menu item called “Inspect page item” displays a small window with a list of attributes.”

What isn’t mentioned is that you only get it by pressing shift-ctrl as you describe. If you press these and don’t click but wander with the cursor over the page you get some useful information, too.

I haven’t had any problems with the WebDevAddition for a long time (with SafariStand, Saft and several others installed). The problems might be resolved with one of the updates.

No.14

Philipe said 1350 days ago:

When I still used Windows I developed with the Webdeveloper extension for Firefox. Then on begin of last year I switched to a PB 15” and still used Firefox, but I soon stopped and switched over to Safari.

Then I found these plugins and I really don’t miss the developer extension at all. I think it can be beaten. And something like editing the source and applying it which is one of the best tools I use isn’t available for Firefox.

No.15

Hrvoje said 1350 days ago:

Sorry, I forgot about the WebDevAdditions luring in the Plugins folder. And unfortunatley it returns references only via “getElementsByTagName”

No.16

Simon de Haan said 1350 days ago:

I’d love to see some webdev extras brought to lovely Camino!

No.17

Daniel Beattie said 1350 days ago:

Best blog posting ever! Thanks so much Jon – I really, really do want to like Safari but I just can’t tear myself away from Firefox since switching to OS X last year. This has given me a lot of food for thought – A DOM Inspector in an aperture window!

No.18

Erwin Heiser said 1350 days ago:

Great round-up of Safari extra’s. Nice one, John!

No.19

Syned said 1350 days ago:

All is very good! It was pleasant to me! Earlier never tried, and I shall use now constantly!

No.20

George Ornbo said 1349 days ago:

The browser pimp strikes again! Just when one of his flock is not getting as much business he wheels out a great article to push the punters in the right direction!

No.21

Logan Williams said 1349 days ago:

How did you get the inspector HUD to be transparent? Mine shows as opaque.

No.22

Jonathan Hurshman said 1348 days ago:

I do a lot of hard-core JavaScript development for an enterprise web application which supports Safari, Firefox, and IE. There are some helpful-looking tools here, which will help make developing for Safari easier.
However, from my perspective, the one tool most lacking for Safari (whether built-in or a plug-in) is a JavaScript debugger. Something like Venkman or FireBug’s new debugger would be wonderful. Is such a thing even possible with the current JavaScriptCore?

No.23

Nebog said 1346 days ago:

Thanks for the information. I shall try to use.

No.24

clem said 1345 days ago:

Nice article; ever since I discovered my new love that is Firefox, and how it helps with my web programming, been a staunch supporter since then. ;) *is proud*

No.25

Yev Webber said 1345 days ago:

Thanks for review it. Will need to test that development tool . May it will good for us.

No.26

Russian Restaurants said 1344 days ago:

#1 Russian Restaurant in Brooklyn New York. See you soon.
Russian Restaurant
http://russian-restaurants.tqgaq.info/russian-restaurant.html

No.27

neil said 1343 days ago:

For me the quality of Safari and it’s extentions/plugins and integration into the app’s UI make it preferable.
I found too many conflicts and amatuerish implementations in FireFox.

No.28

Garito said 1342 days ago:

Hi all!
I would like to know where can I find some manual/tutorial/help about how to write Safari plugins

Do you know where is this information?

Thanks a lot!!!!!

No.29

Jon Hicks said 1342 days ago:

Hi Garito,

There isn’t any – not that I’ve found at any rate. Its not got an official plugin architecture like Firefox, but if you know Cocoa, you may well be able to implement something using SIMBL or as an Inputmanager.

No.30

luxuryluke said 1332 days ago:

Thanks for posting this, this is great, and thanks amillion times for pimpmysafari.com!

No.31

Melissa Galitz said 1331 days ago:

Great post and great site! Good info on Safari. I just stumbled upon your site and I absolutely love your work! Welcome to my bookmarks bar. : )

The Hickensian is the journal of Hicksdesign, a creative partnership of Jon & Leigh Hicks. Read more about us.

Journal RSS Feed

POWERED by FUSION

Elsewhere

The Rissington Podcast - weekly shenanigans with Jon Oxton

Hicksmade - unique handmade goods by Leigh Hicks

Hickr | RSS

Contact

Hicksdesign

Island House

Lower High Street

Burford

Oxfordshire, UK

OX18 4RR

+44 (0)7917 391 536

Click to download my vCard Download vCard

I am currently working full-time with Opera, and not taking on any new projects