News for hackers. Stuff that matters.
Re:Why loading third party scripts async is not good enough by bobds on Wednesday November 23, 2011 @09:54AM (#3270176)
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#D...

Re:Why loading third party scripts async is not good enough by keltex on Wednesday November 23, 2011 @10:15AM (#3270240)
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.

Re:Why loading third party scripts async is not good enough by bobds on Wednesday November 23, 2011 @10:40AM (#3270348)
If 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/Def...