Use Google Adsense Asynchronous Code for Faster Sites

By 29-06-2013   AdvertisingBlogging

Its a good idea to try the new Google Adsense asynchronous ad code for faster loading sites in which the Adsense scripts will continue to load in the background simultaneously and will not slow down loading of your web pages. Asynchronous scripts are the current standard best practice in web design as it allows your webpages to load quickly, and the script does not get in the way of page loading. This also means that you can place the asynchronous script anywhere in the HTML document, and it will not delay the loading of page elements after the script.

In line with Google’s aim to make faster websites, it is recommended that all your scripts should be asynchronous so that they do not delay loading of other page elements.  It is definitely another way to make your sites faster. Remember how you can place Google Analytics code in the HEAD section of HTML without waiting for script loading.

Note that if the JavaScript’s in your page are not asynchronous, you should always add them at the bottom of your page code so that they do not slow page loading times.

Asynchronous Adsense Code

AdSense gives an option to choose the asynchronous script when you get code for the ad unit for your site.

asynchronous adsense code

This is how the earlier AdSense code looked like with the synchronous script

<script type="text/javascript"><!--
google_ad_client = "ca-pub-1234567890";
google_ad_slot = "12345";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

This is how the new AdSense code looks like with the asynchronous script

<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:336px;height:280px"
data-ad-client="ca-pub-1234567890"
data-ad-slot="12345"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Note that currently the asynchronous script is in beta phase testing, which means there could be bugs and errors and they are currently trying to make it better. They recommend that if you have problem in using the asynchronous script, you can continue to use the synchronous script which works for you very well right now. Go ahead and make your site faster.

Update: Note that you can load the async script once only and that will suffice for multiple ad units.

29 comments on “Use Google Adsense Asynchronous Code for Faster Sites

  1. jamiDenmark says:

    Great post, very clean and easy to understand.
    Thanks!

    • LazyGuy says:

      been seeing such a code all the time when logging into adsense but dont know it’s functionality. Great to cross your post

  2. Ian says:

    I think its important that google is recognizing where they could be at fault with load times, they are definitely one step ahead of the curve as I am sure much of the code used on advertisements will be slow to make the same changes.

  3. Vanessa A. Lester says:

    We create a new script tag, set a type and an source, specifies that it should be loaded asynchronously then add it to the head tag of our page.

  4. Sereyboth Yorn says:

    oh! I just hear about “Asynchronous” adsense code today! Will try on some of my fast loading site to test and see!! Thank for the tips!

  5. Android Tutorials says:

    Switched to asynchronous code two days ago and I can see a slight increase in CTR even though traffic didn’t fluctuate much.

  6. PV PIXELS says:

    Good to know about the asynchronous code. I will try that asap.
    Thanks, for the share.

  7. tecmoz says:

    Actually, I don’t know before about Asynchronous Adsense Code. So first I would like to giving thank you for this great information. I will try it in my website to make my site faster. Hope it will work faster.

  8. gaurav says:

    what an amazing style now google is using

  9. Sani says:

    Great to know! Thanks for sharing!

  10. Horace Willis says:

    Opera needs to enable async support by default. Firefox supports the async attribute, and all other browsers (except Opera) will load scripts asynchronously if they are injected as a script DOM element. Opera is the only browser that doesn’t support async scripts out of the box.

Leave a Reply

Your email address will not be published. Required fields are marked *

*