Load Google Adsense Async Script Only Once for All Ad Units

If you use the new Google Adsense Asynchronous script, you can load Adsense script only once even though you might be using multiple different ad units for your pages. Loading the same script repeatedly does not add any benefit, slows page speed,  and this has been confirmed by Google.

Michael Kleber of the Google Ads Latency Team posted code details of the new asynchronous ad code script and says

A script, which only needs to appear once on your page, even if you have multiple ads. It is loaded asynchronously, so it is safe and most efficient to put it near the top.

I also confirmed the same with him on Google+. But note no such announcement has been made by the Adsense team and you might want to verify with them.

confirm Adsense code change

Load Adsense Async Script Once

This means you can load the script only once for all your ad units. A typical ad unit with asynchronous code looks like this –

<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
(adsbygoogle = window.adsbygoogle || []).push({});

Now you can load the adsbygoogle.js script only once. So if you have 3 Adsense ad units you can move the first line of the Adsense code higher up in your html code and use it once only.

<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

This will ensure that the ad code starts loading faster and ad displays faster. The asynchronous code ensures it does not block loading the rest of your site.

NOTE: Please do confirm with Google Adsense team before you start changing your code. While editing Adsense code is against terms of service, in special cases Adsense does allow code modification like that for A/B testing to find the higher paying ads, or for responsive Adsense codes to fit responsive site designs.


  1. Vivek Nath.R says:

    So where should I add the adsbygoogle.js script code, in header.php ?

    • P. Chandra says:

      You can place in header php also. Confirm the script works.

      • Vivek Nath says:

        Hi Chandra,
        I just found the Note about contacting adsense team before altering code. My question is how I contact them? Any contact page for this?

        • P. Chandra says:

          They now have an Adsense help page for what code edits are allowed

  2. Sarang Dravid says:

    I have raised a request for confirming the request with adsense team. Lets hear from them, if this could be done it will surely help with page loading time.
    nice post by the way TFS!


  3. Majk says:

    Async is a beta version? Cause i read somewhere that its not 100% usefull. Do you enjoy using it? cause i feel a little bit scarry to edit a script from Google Adsense

    • P. Chandra says:

      We are using the async scripts. Please remove the extra script only after confirmation from Adsense.

  4. Ryan says:

    This script is working for me.

  5. trucs et astuces says:

    thanks chandra

  6. Badootech says:

    Nice and useful info…its definately worth trying out…hope it works for mee

  7. Brian says:

    Very useful, thanks for sharing Chandra.

  8. Francesca Jewellery Hobart says:

    I have given a request with Google Adsense team, hope this can be done. It will surely be reducing loading time.

  9. Gaurav @ Seo Services says:

    thanks for the valuable information. i am using adsense on almost all of my blogs hope these tips will definitely help me.

  10. CHRISTOPHER says:

    Thanks Ms. Chandra for this post. I will recommend this to my friend so i don’t have to spend more time explaining about the same issue to my friend. This post helps me much. Cheers! :)

  11. Lupe Cain says:

    If you are planning to have multiple AdSense ad units on the same page, the same code will work except that you need to replace google-ads-1 with google-ads-2 in line # 1 and 6. The adsbygoogle.js script in line #40 only needs to included once in your web page. You may as well place it at the bottom on your page just before the the closing </body> tag.

Leave a Reply

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