Back

New Feature: Non-blocking, Asynchronous Ad Code

Portrait of Todd Garland
by Todd Garland
Jan 1, 2010

In geek-speak, asynchronous is a heavenly term. Nearly all advertisements on a website are served using JavaScript from a third party ad network provider. When any browser downloads the ad code that displays the ads, it blocks everything else on the page from rendering. And, while this process may take less than a second of the user’s time, it is noticeable and it is a big problem.

Remember the day Michael Jackson passed away? Several news websites were crushed by the traffic and crashed. It wasn’t because the news websites could not handle the traffic; it was the ad networks blocking ad code that slowed things down. It is a known fact that ad networks are a key bottleneck when it comes to website performance. We decided that it was time for some innovation in ad code delivery methods, and are proud to announce our new non-blocking, and truly asynchronous JavaScript ad code.


Photo by Roland Tanglao

If the major ad networks like Google AdSense, Yahoo! Network, AOL Advertising, as well as the popular ad serving products such as Google AdManager and OpenX converted their ad code to be non-blocking, the internet as a whole would become an order of magnitude faster. I genuinely hope that the larger ad networks will step up to the plate and follow our lead on this. A faster internet is a happier internet. This is a big deal.

Why is this a big deal?

 
  1. Speed: Plain and simple: your website will load faster for your visitors. JavaScript is a performance burden on your website. It blocks additional resources in the page from downloading and blocks elements below from rendering (see Steve Souders Loading Scripts Without Blocking article for more info). It has also been rumored that site speed may soon affect Google page ranking.
  2. Better Data: It is generally accepted that ad networks will report slightly different impression level data than your website analytics software. There are a variety of reasons for this. Slow or partial page loads is one of these reasons. Faster ad code means fewer slow or partial page loads and therefore better data.
 

Why should you care?

Let’s face it, ad networks slow down the internet. Since online advertising is part of our livelihood it is important for us to do what we can to make online advertising less evil. Making websites load faster is important.

How can you get the new snippet?

Login to your BuySellAds.com account and go to your Publisher Dashboard. Click on the “get ad code” link for each of your ad zones and follow the instructions on that page. The main snippet below will need to be installed right after the openingtag:

<pre lang="javascript"><!-- BuySellAds.com Ad Code --><br>
<script type="text/javascript">// <![CDATA[
(function(){
var bsa = document.createElement('script');
bsa.type = 'text/javascript';
bsa.async = true;
bsa.src = '//s3.buysellads.com/ac/bsa.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(bsa);
})();
// ]]></script>
<br> <!-- END BuySellAds.com Ad Code --></pre>

Then, for each ad zone, you will need to install the following snippet where you want the ads to appear. Note: this snippet will be unique for each ad zone, please get the appropriate snippet from the “get ad code” page for your ad zone (this link is on your Publisher Dashboard):

<pre lang="html">&nbsp;</pre>

Important: If you install the new version of the ad code, you MUST install it for all of the ad zones on your site. If you don’t, there is a chance for a race condition here and there if the bsa.js asynchronous ad code has not downloaded by the time the browser tries to render each zone.

Of course, your current install of the BSA ad code will work just fine, but it’s in your best interest to upgrade to the new BSA ad code install to reap the performance improvement. This async install of the BSA ad code is now our default install and we will be working to encourage publishers to make the change until we can phase out the legacy version 100%.

Special Thanks

We would not be “clued-in” to techniques and methods for doing this without the work of Google Evangelist and YSlow creator Steve Souders. His book High Performance Web Sites is a must read, and we also suggest keeping up with his blog – there is a wealth of information there now, and he will be publishing some posts in the coming weeks on 3rd party content (ads, widgets, analytics) that I am sure will be valuable. Steve was also kind enough to take a look at our snippets before todays release.