Walter Rumsby's Web Site

On DOM Ready

26 Jun 2008 at 14:30

YUI provides the YAHOO.util.Event.onDOMReady method which "lets you define a function that will execute as soon as the DOM is in a usable state."

I've heard reports (both internally and on the YUI mailing list) about this method going a bit haywire - specifically firing before the DOM is usable - in Internet Explorer, but these seem to be in weird situations and it has been (seemingly) impossible to create a test case to demonstrate when/where/why this problem happens. This makes it pretty difficult to raise a bug that the YUI team can look at, so the problem still (apparently) exists.

I was looking at an old post by Dean Edwards that suggests using the script element's defer attribute to work out when the DOM is "usable" in IE. Edward's solution suggests using conditional comments to remove the defer attribute for non-IE browsers, but I wonder if that's even necessary.

This leads me to think, assuming your external script is entirely wrapped up in an onDOMReady function, why not throw a defer attribute onto the script element? My hunch is:

  • IE will defer the script's execution until the DOM is usable.
  • Other browsers will ignore the defer attribute, but since onDOMReady works for those browsers (assuming they are A Grade browsers) they will also wait until the DOM is usable.
  • By the time IE trys to work out if it should fire onDOMReady the defer attribute will mean that it's okay for it to fire, so you should sidestep the "onDOMReady fires in IE before the DOM is usable" issue.
  • All of this will happen before the window's load event fires regardless of browser.

I've set up an example page which appears to confirm this, but of course this page doesn't suffer from the incredibly tricky to replicate problem so this is very much a guess at a solution. The other thing is this assumes that all the code in your script runs inside an onDOMReady function, which might not be what you want.

I've followed this up with a message on the YUI mailing list to see if anyone can spot any problems with this approach and plan to update this post with anything that comes out of that.

Update: there is now a bug with test cases. Hopefully this is resolved in the next YUI release, but in the interim, or if you are using an older YUI release, it appears that adding the defer attribute to script elements does avoid these errors.

Next Previous Navigation

22 Jun 2008 at 17:46

FFFFOUND! is a social bookmarking site for images (only).

I quite like it. It feels like flicking through a book or magazine full of interesting images and I think one of the reasons that they're able to achieve this is thanks to the incredibly useful, and simple, navigation options they provide.

In the top, right corner of the browser window are some navigation links which also come with clearly indicated keyboard shortcuts.

I find it really useful to be able to hit the j key and navigate through the images in a way that's a whole lot nicer than hitting Page Down Page Down doesn't know where images begin and pretty quickly you'll have to fiddle with the scroll bars to fix things.

I've hacked together my own ultra-basic version of this for the posts page here in the hope that it is useful to some people.

(This is currently not so great in IE6).

A Few Weeks Ago

02 Jun 2008 at 15:01

Sniff in he snow

Photo by Charis

Test

10 Apr 2008 at 22:57

Klute is playing in Queenstown on May 13.

You need Flash player 8+ and JavaScript enabled to view this video.

Webstock: The Final Countdown

19 Feb 2008 at 10:30

It's Over

Well, here we go. Assuming my addition is correct here is the final memescore for Webstock 08:

Popular memes at Webstock 08
Meme Mentions
Twitter 12
Flickr 14
iPhone 10
LOLcats 8

I'm sure some people will be surprised that the LOLcats count is so low.

There were a few other topics that got frequent mention. History was quite a common thread - Nat Torkington started it all off with the Crimean War, Liz Danzico talked about Miles Davis' Kind of Blue, Scott Berkun talked about Guttenburg and Newton, Jason Santa Maria talked talked about graphic design during the Renaissance and I'm sure if I scour my notes I can find more examples. Last.fm also got a few mentions as did Facebook. Russell Brown talked about SuicideGirls (I think he has a wee crush on Posh - but given that she is an attractive, creative, Mac fangirl who spends her spare time playing WoW and dates the owner of an independant media site maybe that's not so surprising).

So how did Webstock 08 rate? My opinion has shifted a bit over the last few days. Initially I thought the event wasn't as strong as 06, but thinking about it more that's probably because I attended two full-day workshops in 06, and only one half-day workshop this time. When it came to the actual conference I think I actually got more from the general conference speakers this time round (I've already made a series of redesigns to this site based on Luke Wroblewski's workshop and presentations by Dan Cederholm and Simon Willison).

To be honest my big mistake this time was probably forgetting to go to the Matterhorn (technically speaking I did pop my head in the door trying to find some Webstockers who ended up being next door at Mighty Mighty).

Over the next few days (or weeks) I'll post some more detailed entries on my favourite presentations - Liz Danzico, Tom Coates, Dan Cederholm and maybe a few others - plus the Luke W workshop, but as a general review of the whole event I'll have to say well done again Webstock.

Just to emphasise that point, on Friday evening I was chatting to Tom Coates and along came Nat Torkington who said hullo (to Tom). They both agreed that this was one of the best conferences they had ever been to. So I wouldn't be surprised if O'Reilly conferences borrow one or two ideas.

Meanwhile, I'm already looking forward to the next Webstock.

Scorecard: The 8 x 5 Session

17 Feb 2008 at 14:30
Speaker Twitter Flickr iPhone LOLcats Score
Total 3 2 0 1 6
Nigel Parker YES YES 2
Brian Calhoun 0
Mike Riversdale YES YES 2
Sam Farrow YES 1
Mark Zeman 0
Mark Rickerby 0
Tahi Tait 0
Provoke YES 1

Scorecard: Day 2, Afternoon Sessions

17 Feb 2008 at 13:30

Scott Berkun

Speaker Twitter Flickr iPhone LOLcats Score
Total 1 3 2 1 7
Dan Cederholm YES YES YES 3
Scott Berkun YES 1
Damian Conway YES 1
Kathy Sierra YES YES 2

Scorecard: Day 2, Morning Sessions

17 Feb 2008 at 13:26
Speaker Twitter Flickr iPhone LOLcats Score
Total 2 2 2 2 8
Russell Brown YES 1
Simon Willison YES YES YES 3
Tom Coates YES YES YES 3
Michael Lopp YES 1

Archive

Login

Syndicate

About Me

I'm a software architect living in Queenstown, New Zealand.

Elsewhere

Wish Lists