New Feature: Non-blocking, Asynchronous Ad Code

Comments (93) Wednesday, February 10 by Todd Garland

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.

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?

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.

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 opening <body> tag:

<!-- BuySellAds.com Ad Code -->
<script type="text/javascript">
(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>
<!-- END BuySellAds.com Ad Code -->

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):

<div id="bsap_[zone]" class="bsarocks [sitekey]"></div>

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: http://www.stevesouders.com/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.

header image copyrighted by Roland

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Design Float
  • DZone
  • LinkedIn
  • Reddit
  • StumbleUpon
  • TwitThis
  • Yahoo! Buzz

93 Responses to “New Feature: Non-blocking, Asynchronous Ad Code”

  1. Niki Brown says:

    Todd – keep up the great work. BuySellAds just keeps getting better and better!

  2. Ryan Barr says:

    Congrats, guys! What a great feature to be a part of.

  3. Congrats on the big upgrade, look forward to speeding up my sites :)

  4. Saud Khan says:

    I believe we need to put “Main snippet” in the Footer instead of the HEAD tag.

  5. cheth says:

    Nice move! I’m updating mine asap. :)

  6. Johnathan says:

    Code didnt work when placed in header but when placed below header it worked…

  7. I believe you can remove the line: bsa.type = ‘text/javascript’;
    … since all scripts without the type attribute are assumed “text/javascript”.

    Also, shouldn’t you be setting the “async” attribute to either “async” or an empty string, as per the HTML5 spec? (see: http://dev.w3.org/html5/spec/Overview.html#boolean-attribute)

  8. redwall_hp says:

    I just switched to the asynchronous code, and it seams to work fine for the most part. Except the ads don’t always load on my permalink pages. If I force-reaload the page they load fine, but they don’t if I just visit them normally. And if I reload the page (non-forcing) the ads, again, don’t show up. What’s going on?

  9. How long does it take for the custom CSS to pick up? I have made some changes, but these CSS changes don’t seem to work for me :-( (tested with FireBug)

    • It should pick up right away, within a few seconds. There certainly is a chance that it’s not getting to our edge location in Amsterdam that fast for you, however. Where I am (Boston) I’m seeing the custom css you added (with Firebug also). If you are not seeing it by the time you get this comment notification, please ping us at support@buysellads.com so that we can test out the latency a bit more for the Amsterdam edge :)

      • Thanks Todd, but I think this was a caching issue on my side. Just quitted Safari and empty its caches and it’s fine now (all other browsers I was able to test as well).

        Great addition by the way. Really speeds up our homepage load time!

  10. Scorpiono says:

    Fantastic innovation.
    As I recall, in the last blog posts we had another speed optimization.

    Let’s speed up the internet one step at a time!

  11. Jensa says:

    Installed the code in 10 minutes – works like a charm. There’s one thing that does not validate according to the w3c validator:

    Attribute “rel” exists, but can not be used for this element.

    …”bsap_1237474″ class=”bsarocks” rel=”f0e2d4a2e2ba2b3f701e20ef61b8bfb5″>

    Any way to fix this?

    J

    • Yes, this was an oversight on our part and we’re working on a fix so that we can get the value from something other than the rel attribute that’s causing validation to fail. I will post here when we have that ready and we’ll also be updating the get ad code page in everyone’s account. If people have already installed the new ad code and do not care about this validating, the ad code will still support what they have already installed.

    • Hi Jensa, just wanted to let you know that we have switched this up a bit so that the code now validates :)

  12. Toni says:

    In Firefox 5 the Advertise Here box doesn’t appear:
    http://wallpaperstock.net/

    Only the ads appear.

  13. Still have some significant issues with the ads “not firing”… argh…

    • fyi, we have about a dozen people with this issue right now and are working on a fix. We will post here when it’s all set and also email each of the people who have reported to let them know what to do next.

      • Kristina says:

        Please count me in with this issue on ’spotty’ ad firing. Thanks very much! Love it regardless!

        • thanks for the feedback. we’re working now to finish up final testing on our fix for this issue that is happening with about a dozen users. once we finish testing for each case to be 100% certain we will push out the new release and life will be good for us all :) I will post an update in the comments here and also email each site owner personally.

        • fyi, as we confirmed via support, everything is all set now.

  14. Very cool feature, nice work Todd!

  15. Kristina says:

    Yay! Going to implement it right now.

  16. ahith says:

    not working properly.. some ads not showing up… reverted back to normal code. waiting got update……

  17. Kristina says:

    As an update, for some reason ads only show up after refreshing the page, but not on first load. I am using WP Super Cache, not sure if this is the issue. Also, the new CSS is not implementing the proper margins I have put in the CSS (default) via the new system: margin right is showing up as 0px even though it should be 4px (this is with the float:left method).

    On another note, strangely, the ads aren’t showing up at ALL on my index templates (home page, page 2, etc) or single posts, but are on my wordpress “pages”.

  18. Dana says:

    The horizontal side by side 125×125 do not work for my blog. It is working find witouth float:left; in Anchor Style — but when i put float:left; in Anchor Style, my sid bar area in the mess. It seems do not work with my widget style — is there any way to make it work?

  19. Hi Todd
    My problem is, I want to display the ads as two-column in the widgets. How
    now I have to codes and snippets where i should put them ? in header.php or footer.php and which of the snippets i should put it in the widgets box ?

  20. Quan says:

    Thanks Todd. Everything is perfect now :)

  21. Klodian says:

    Hey guys, this code is simple gr8, just patient and replace all code with new one for all your ad places not for only one, after u will see that CSS is ok :)

  22. Naeem Noor says:

    Great work Todd, just updated the code on my blog :D

  23. Jebby says:

    Although the new code loads ads more fast but still i have a problem! My 125×125 ads are not shown horizontally even after adding float:left; to the Anchor Style :(. All 125×125 ads are shown vertically in a line making my sidebar even more worse in look :(
    I cleared my cache but the problem still persists. I have all zones with new code and the main snippet is places just after the body tag! Please help!

  24. hi Todd,

    please technically explain why you cannot place the script in the HEAD, but only in BODY?

    Txs!
    Aaron

  25. Hi can someone please contact me from buysellads.com, you do not seem to have a contact form and I do not wish to click 10,000 links to get an answer to a simple question

  26. The new code doesn’t allow you to call the code twice for pages that you want to show the ads above and below the fold. For example, if you have ads at the top of the page in the sidebar and want the ads to show again at the bottom of a very long post, it will not work.

    Is there a fix for that?

    • To make multiple drops of the same zone on a page, add “_1″, “_2″, etc to the ID of the containing div. For example, when you grab the ad code from your account it will be something like:

      <div id=”bsap_[zone]” class=”bsarocks” rel=”[site]“></div>

      You just need to append the _1 to the id for the second drop:

      <div id=”bsap_[zone]_1″ class=”bsarocks” rel=”[site]“></div>

  27. DailyCoder says:

    This ad installation code in not working on chrome and firefox, however its working on IE

    • can you send us some more details in a suport ticket? The code’s woking fine on many sites right now, so I’m sure it’s something we can help you with.

Trackbacks/Pingbacks

  1. [...] the ad network that I use on Webmaster-Source, has introduced a cutting-edge ad-serving feature. Their new asynchronous ad serving script dramatically speeds up page loading times, as the browser doesn’t have to wait around for the [...]

  2. [...] it’s so easy to get the code, it’s even fun to style it the way you want after they upgraded to the new ad code and added new features, I didn’t even need to contact support even once till now, although I [...]

  3. [...] in which they can improve ad loading times. She hints at HTML5 saving the day and also mentions BSA’s asynchronous ad code.Steve Souders, a pioneer in website performance and Google’s Performance expert, did some [...]

  4. [...] still into ads, but we took the two year anniversary party to a new level and (after launching the asynchronous ad code and introducing the Image + Text ad format) we ended up with a track and now a video featuring a [...]

  5. [...] we’re passionately committed to, it’s speed. We’re the first (and only) ad network to have non-blocking asynchronous ad code. This means that your website will load faster for your visitors. Don’t believe us? Top [...]

  6. [...] New Feature: Non-blocking, Asynchronous Ad Code [...]

Leave a Reply