This post shows you how you can call your JavaScript functions once the Document Object Model is ready (which is a lot faster than waiting for the page to finishing loading when using window.onload).
The following code is an amalgamation of the work of Jesse Skinner and Byron McGregor. It keeps track of the methods passed into the addDOMLoadEvent function and supports all modern browsers such as Firefox, Chrome, Opera, Safari (higher than 525) and falls back to window.onload for those browsers that fail all the other checks.
I’ve also updated the code to take into account one particular issue I found with previous versions when using the doScroll method of targeting Internet Explorer which would sometimes return “unavailable”, as well as fixing a Firefox error when hitting the Safari targeted code.