Google makes web pages faster with a simple tweak
Written by Ian Elliot   
Friday, 18 March 2011

Google has manged to speed up the way that it serve AdSense content to web pages by a simple change to the JavaScript that does the loading. The ungrateful among us might be asking - why has it taken so long to fix?

Google has been rolling out the new version of show_ads.js which it reckons is used by more than two million websites which show AdSense ads. The new version is supposed to be faster but it seems what is really meant is that it doesn't block page loading for as long and allows overlapped operations that appear to speed things up. In practice this is often as good as a real efficiency improvement because the user isn't kept waiting for as long. 

The approach creates a "same origin" i.e. safe iFrame and then runs the old show_ads script, now renamed show_ads_impl.js. The old script does everything it did before but now within an iFrame. So not much change and the ads, of course look the same.

adsenselogo

The reason this all works faster is that many operations within an iFrame are non-blocking to the loading of the rest of the page. This essentially converts the loading of ads from synchronous to asynchronous.

It is amazing that the change is so simple and makes you wonder why creating and using the iFrame approach isn't used more extensively to decouple the loading of different parts of the page. Google says that everything isn't completely plain sailing as iFrames are treated in different ways by different browsers and so currently the change is only being made for Chrome, FireFox and IE8. So if you think that IE9 is running slower than the opposition you have one possible reason. 

Just in case you are doing custom things with AdSense ads that are not compatible with the new iFrame approach, you can turn it off by setting  

google_enable_async = false

for any individual ad slot to revert to the old blocking behavior.

The advantages of using iFrames in this way has been known for some time but you can hardly complain at Google being slow to update its ad serving code  when so many website buttons and widgets still you barbaric approaches based on document.write ?while others block loading completely. If you expect other sites to use your buttons and widgets make sure they don't block and that they fail gracefully.

 

Banner


MOOC On Functional Programming Using Haskell
16/10/2014

Erik Meijer's Introduction to Functional Programming MOOC has just started. If this is a topic you want to know more about, this free class could be an ideal route.



Google Adds Firebase To Its Cloud
23/10/2014

The acquisition will add the Firebase backend service to Google's Cloud Platform lineup making it easier for developers to sync data across web and mobile apps.


More News

Last Updated ( Friday, 18 March 2011 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.