Google's Shiny AdSense async JavaScript Code

By Xah Lee. Date:

Google AdSense has a new async code for their ads.

this is before:

<script type="text/javascript"><!--
google_ad_client = "ca-pub-dddddddddddddddd";
/* 160x600 */
google_ad_slot = "dddddddddd";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

this is after:

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

if you haven't upgraded, go to your AdSense site, and get new code, and start migration!

what this means is that, before, if you have ads on top of your page, and if the browser can't fetch it for some reason, the rest of your page won't render, until it times out many seconds later.

now, with async code, your page will render regardless whether the AdSense JavaScript is loaded or not. So, happier experience for your readers.

you can read their announcement here: [Faster, more robust web with AdSense By Google. At http://adsense.blogspot.com/2013/07/faster-more-robust-web-with-adsense.html , accessed on 2013-09-12 ]

to understand async JavaScript, see: