Tuesday, June 12, 2012

Defer third party scripts/ads until after the page has finished loading

Contents are loaded according to the components' order in the HTML source code. If you want visitors to see the site contents before seeing the ads to improve performance and visitor experience, you can choose the IFRAME serving code format, which loads independently from other components on the page. The other option is deferring the fetching and loading ads into DIV containers. This technique can be useful for websites that use asynchronous loading like AJAX or want to avoid JavaScript's document.write() approach. 

Why loading third party scripts async is not good enough:

Loading third party scripts async is key for having high performance web pages, but those scripts still block onload. Take the time to analyze your web performance data and understand if and how those not-so-important content/widgets/ads/tracking codes impact page load times. Maybe you should do what we did on CDN Planet: defer their loading until after onload.

Delay the loading of 3rd party javascript:
 
All of us have a lurking failure in our websites: 3rd party scripts from ads, widgets, and analytics. How is it that one script can bring down your website?