4 ms·
It helps the end user experience if you want to have some javascript run after the DOM is loaded but not wait until all the 3rd party scripts have loaded and ru
by keltex 15y ago
It helps the end user experience if you want to have some javascript run after the DOM is loaded but not wait until all the 3rd party scripts have loaded and run. Maybe the javascript runs some sort of animation.
Without this code, the animation would wait until facebook, google + and twitter are all loaded, but with this code, the animation would start right away.
- bobds 15y agoIf a script is supposed to run when the DOM is ready but external scripts/stylesheets/etc are still being loaded, it should not attach itself to the load event. The load event is supposed to run when the page has fully loaded. By the way, IE9 now supports DOMContentLoaded and there are hacks to simulate it in earlier IE versions. Here is a demonstration: http://ie.microsoft.com/testdrive/HTML5/DOMContentLoaded/Default.html http://ie.microsoft.com/testdrive/HTML5/DOMContentLoaded/Def...