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 type="text/javascript"

this is after:

<script async src=""></script>
<!-- 160x600 -->
<ins class="adsbygoogle"
(adsbygoogle = window.adsbygoogle || []).push({});

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 , accessed on 2013-09-12 ]

to understand async JavaScript, see:

JavaScript in Depth