Use Google Adsense Asynchronous Code for Faster Sites

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="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

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

<script async src="https://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.

Share with friends

32
Leave a Reply

Leave a Reply

  Subscribe  
newest oldest most voted
Notify of
jamiDenmark
jamiDenmark

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

LazyGuy
LazyGuy

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

Ian
Ian

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.

Vanessa A. Lester
Vanessa A. Lester

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.

Sereyboth Yorn
Sereyboth Yorn

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!

Android Tutorials
Android Tutorials

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

PV PIXELS
PV PIXELS

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

tecmoz
tecmoz

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.

gaurav
gaurav

what an amazing style now google is using

Sani
Sani

Great to know! Thanks for sharing!

Horace Willis
Horace Willis

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.

Wdc Website Design
Wdc Website Design

Were just starting to use adsense in a few of our clients sites so will give it ago,thanks for sharing

Romeo Q. Warner
Romeo Q. Warner

As said above, the page will load faster, but we might end up dealing with some minor effects. For example, the asynchronous loading of the external resource could move page elements after the page is loaded, causing an unwanted “resetting” of some elements (like the sliding of a container). In other cases, some functions might be available to the user with a small delay, giving the impression that the page froze for a moment. Those counter-effects can be solved by carefully placing the loaded content (‘http://externalDomain.com/script.js’) in the right spot or, for example, creating the needed space when the page… Read more »

Siddhartha Sinha
Siddhartha Sinha

Thanks for information on Google Adsense Asynchronous and Synchronous as I was not knowing this information

Alex
Alex

Thank you, was unsure if I should check out the new BETA codes.

Madeleine J. Sargent
Madeleine J. Sargent

put a huge smile on my face. Blocking is a huge bottleneck for every website and the ability to easily direct a script to load asynchronously should speed up the web!

Jeri N. Mccarty
Jeri N. Mccarty

The simplest solution is to keep all of your scripts inline at the bottom of the page, that way they don’t block the loading of HTML content while they execute. It also avoids the issue of having to asynchronously load each required script.

Vito Blair
Vito Blair

I’m pretty sure this still qualifies as asynchronous because the resource they are loading is a script-injected script, meaning it won’t parser block.

Price
Price

When you dynamically append a script to a page, the browser does not halt other processes, so it continues rendering page elements and downloading resources. The best place to put this code is right after the opening body tag. This allows Facebook initialization to happen in parallel with the initialization on the rest of the page.

sararith
sararith

Wow, Loading website fast is what the web master and visitors really need. without adsense i can’t create blogs and update it often. Thanks for the tips.

Jerry T.
Jerry T.

Great tips, I have never thought of this but testing it out could be very useful.

SAJID
SAJID

Using Ashynchronous on all of my sites…:)

John 168
John 168

I’ve never think about this point. Adsense also relevant to our site speed. Thanks for this great info while I’m trying to find more on how to increase my site speed now.

John 168
John 168

I’ve never think about this point. Adsense also relevant to our site speed. Thanks for this great info while I’m trying to find more on how to increase my site speed now. John.

jerry t.
jerry t.

I had wondered what the difference between synchronous and asynchronous code meant.

Wendy William
Wendy William

Thanks! I was unsure whether I should check out the new BETA codes.

Chaserey
Chaserey

Yes i agree with you after using Adsense Asynchronous Code make the performance of my site faster than before. I have tested it last month. Anyway, thanks this great tips.

Wendy4ever
Wendy4ever

I try the asynchronous code as soon as possible. Thanks for sharing this usful tips.

Sophea
Sophea

Thank you share best tip. I always with slow loading of my site when I use more adsense banner in the same page.

Thank you

Mack Shark
Mack Shark

I can find money online by Adsense but google always block my Adsense many times. thank you for sharing this information :)

Mark
Mark

I’m planning to place Adsense in my site without interfering site’s performance. And this tip is of help. Thanks for sharing!

Jen Hoo
Jen Hoo

Thanks for posting, I really enjoyed reading and certainly will be taking your advice and learning from your tips