onDOMLoad

[via Keebler/Blog]

Most people attach their initialization behavior to an onload event, waiting for the page to finish loading before manipulating the DOM. One problem with this, though, is that onload doesn't fire until everything on the page is finished loading, including all images. It can take several seconds, or more, for every image to load, especially on Internet Explorer since there is a two connection per host limit.

The folks at brothercake have posted a nifty onDomLoad script that solves this problem:

"domFunction is an easy-to-use helper script, that allows other DOM scripting to run before window.onload; the practical benefit is that javascript doesn't have to wait for images or other dependencies to finish loading anymore - it can begin as soon as the DOM is ready."

Check it out.

Comments