DOMContentLoaded for Browsers, Part II

Update: 2014 March 19 - domReady version II has been created that provides a streamlined domReady function.

Update: 2008 June 13 - DOMContentLoaded for Browsers, Part V has been created that provides a domReady function without the overhead of the Dean Edwards' events code. If you're a prototype user you should check out Prototype JavaScript framework: document.observe which in version 1.6.0 gives you a dom:loaded event. If you don't have 1.6.0 or above of prototype or don't like their solution, check out domready.js in DOMContentLoaded for Browsers, Part V.

Update: 2006 Jul 10 - Fixed Firefox 2.0 problem and added ability to add a custom content ready function, DOMContentLoaded for Browsers, Part III

Update: 2006 Nov 28 - Changed code to support IE and https.

Update: 2006 Nov 21 - Added code to support IE and https.

Update: 2006 Jul 4 - Added Safari and KHTML specific code to load DOMContentLoaded events.

Update: 2006 Jun 26 - Code works in Opera 9. Now you can speed up onload events in most grade A browsers by using DOMContentLoaded/ContentReady events.

Dean Edwards has done it again. Thanks to work done by Matthias Miller, Dean has written a solution that removes the requirement of an external JavaScript file for Internet Explorer. My previous article, DOMContentLoaded for Browsers, used two external JavaScript files, ie_domload.js and events.js file to add DOMContentLoaded events. After adding Dean's new code to allow events.js to run the DOMContentLoadedInit function without an external JavaScript file for IE, I cleaned up the code that calls the DOMContentLoadedInit function to allow for browsers that will, or have added the DOMContentLoaded event. I believe that Opera 9 has added the DOMContentLoaded event. If anyone could test the sample page Opera 9, I would appreciate it.

Continue Reading "DOMContentLoaded for Browsers, Part II..."