Dom Ready now with added Curry!
The cross browser DomReady event is a great feature in all the good JavaScript libs. Basically you use it where you'd normally use the window onLoad event, the only difference is that it doesn't wait for images and other large assets to load before firing. So when people are in a hurry or the page is just slow they don't get a lessened experience because your progressive enhancements haven't done their enhancing.
Quite often you don't want to use a library, like when you're trying to make a simple standalone util. So here's a simple standalone cross browser DomReady script, tested in a few versions of IE, FF and Safari (should be fine in Opera).
Here's how to use it in it's simplest form.
Here's how to use currying, the second argument is the scope that the method is fired in and the rest of the arguments are passed to the method.
So this would call the function fHandler, when that function uses this it will refer to MyNamespace and it's one argument is a string containing init
Labels: javascript


Comment Feed


Array.prototype.slice.call(arguments, 2);
...to chop the first two off.
Courtesy of Dan Webb.