Google's Shiny AdSense async JavaScript Code

,
Want to master JavaScript in a week? Example based, to the point. Xah JavaScript Tutorial.

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 = "4521229185";
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="4521229185"></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. @ adsense.blogspot.com…

to understand async JavaScript, see:

blog comments powered by Disqus