3 ms·
I am not sure what this accomplishes, other than making the stats look better in their monitoring tool. They pretty much seem to admit this: "Conclusion: the l
by bobds 15y ago
I am not sure what this accomplishes, other than making the stats look better in their monitoring tool. They pretty much seem to admit this:
"Conclusion: the loading, parsing and executing of the async third party scripts are quite often very slow and this messes up our End User performance stats in New Relic."
Delaying the dynamic insertion of scripts until after the onload event, doesn't change anything. All the external crap will still be loaded. It might even make the external assets load slower.
Another solution would be to choose a monitoring tool that distinguishes between DOMContentLoaded (or the equivalent in non-Gecko browsers) and the regular onload event.
https://developer.mozilla.org/en/Gecko-Specific_DOM_Events#DOMContentLoaded https://developer.mozilla.org/en/Gecko-Specific_DOM_Events#D...
- keltex 15y agoIt 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...