Stumble Digg Technorati Delicious

Blazing Fast Ads, Don’t Let OpenX Slow You Down

If you serve your own advertisements using OpenX you are among the growing number of people that have taken control of their own ad serving platform. I have been using it on clients sites as well as my own sites for several years and have no plans of changing to any other system, OpenX has worked very well for me on small sites as well as high volume sites with thousands of ads.

What many people don’t know however is that by default OpenX wastes resources and slows down the loading of your pages and in some instances can cause your page load times to be so terrible that people will just move on to another site. I should clarify this a bit, it’s not the fault of OpenX as they do make available the option to rectify this, but its not a default thing and many people never look any further than the quickest and easiest way to serve your ads on your site.

If you install OpenX on your own server, you will likely be using a bit of code in each ad location that looks something like this:

<script type=’text/javascript’><!–//<![CDATA[
var m3_u = (location.protocol==’https:’?’’:
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = ‘,’;
document.write ("<scr"+"ipt type=’text/javascript’ src=’"+m3_u);
document.write ("?zoneid=11");
document.write (‘&amp;cb=’ + m3_r);
if (document.MAX_used != ‘,’) document.write ("&amp;exclude=" + document.MAX_used);
document.write (document.charset ? ‘&amp;charset=’+document.charset : (document.characterSet ? ‘&amp;charset=’+document.characterSet : ”));
document.write ("&amp;loc=" + escape(window.location));
if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
document.write ("’><\/scr"+"ipt>");
//]]>–></script><noscript><a href=’;cb=132354835318351′ target=’_blank’><img src=’;cb=554851354385368516846843&amp;n=a3832040′ border=’0′ alt=” /></a></noscript>

While this will work just fine, it’s not ideal as every single ad you serve has to be called from your server one at a time, if you have 10 125×125 ad banners in your sidebar, a banner in your header and 2 or 3 other ad placements on your site using this format can have a dramatic impact on your overall site performance.

Don’t worry though, its easy to do it the right way. OpenX offers an option to include your advertisements using what they call “single page call” serving. What this basically does is put one javascript code in your header to make it available on all pages and you simply insert a small invocation code for each ad position, doing it this way all the ads for the page are called from OpenX at once, reducing server load and speeding up the loading time of your page dramatically.

So, just what is the “official” definition of single page call, well according to OpenX Single Page Call is an invocation tag which can help reduce the load on your server and deliver ads faster. The single page call ad tag uses a JavaScript invocation method to make one HTTP request no matter how many creatives are being displayed on a page, rather than each request being made sequentially and slowing down your page load times.

The invocation code for single page call is handled at the website level within your OpenX installation, simply log into your admin section and click on Inventory, then websites and select the site you want to implement this on. Once you click on the site you want (if you have more than one there) you will see a row of tabs across the top, simply click where it says “invocation code” and select the options as you would normally and click generate.

Once generated you will be looking at a page containing all the codes for the zones you have set up for that site, it breaks them down by number and even shows you a box simulating the size and shape of the ad in that zone.

In order to implement this method of ad delivery you must insert a piece of code to your header that looks like this:

[php]<script type=’text/javascript’ src=’;blockcampaign=1′></script>[/php]

Then you insert the individual code for each zone in their respective locations, these codes will look something like this:

<script type=’text/javascript’><!–// <![CDATA[
// ]]> –></script>

As you can see, this isn’t a terribly difficult process and the benefits can be dramatic. If you are using OpenX I strongly encourage you to use this method if you aren’t already. Any questions or comments, you know what to do.

26 Responses to “Blazing Fast Ads, Don’t Let OpenX Slow You Down”

  1. Comment by Jesse posted on October 28th, 2009

    test comment

    Reply to this comment

  2. Comment by Claude posted on November 13th, 2009

    This technique is also useful for anyone running WP-Super-Cache or WP-Cache on their blog.

    I am still not happy with the three includes (one inline and two dynamic) in the page's header since the page appears slow. The ideal solution would load all the JS at the bottom of the page and the ads could be injected after the content has loaded.

    Reply to this comment

  3. Comment by Jesse posted on November 14th, 2009

    Yes, this is effective with various caching plugins or systems. I have been
    working on a solution to accomplish a few things with openx but haven't had
    time to complete them yet, once I do I will post about it on here.

    I have found that using this method is the best “interim” solution for now,
    with the use of server based caching of php and mysql along with combining
    and minifying my scripts and css and putting my static content on a cdn I've
    knocked my homepage load time down to the low 3 second area which works for
    me for the time being.

    Reply to this comment

  4. Comment by Claude posted on November 17th, 2009

    3 seconds is a decent load time.

    I'll try to spend some time on a delayed loading solution for the ads using OpenX. I really like the server and need to *fix* this in order to put it in production at work.

    Reply to this comment

  5. Comment by Jesse posted on November 18th, 2009

    I'd definitely be a fan of that implementation, keep me posted on how the
    “fix” works out for you :-)

    Reply to this comment

  6. Comment by Francine posted on December 6th, 2009

    I was able to speed things up even more by making the javascript file local — just copying the linked js file into a file on my server and calling that one. It makes a noticeable difference from calling the remote file. I would still like to load it after the rest of the page like some of you, too. There is still a slight delay with when some information shows up on the page because of OpenX, but it's only by about a second.

    Reply to this comment

  7. Comment by Jesse posted on December 6th, 2009

    I've been pretty happy using the self hosted version but for those who are
    using the Openx hosted version this may be helpful. It is still on my list
    of things to improve once I have some time to set aside for it but overall I
    am very happy with the results I have gotten from it.

    Reply to this comment

  8. Comment by Joe Panettieri posted on December 7th, 2009

    Jesse: I am editorial director of several websites using OpenX and WordPress. Can you please email me (joe [at] I'm located in NY and would welcome the opportunity to discuss the potential fixes you mentioned above.

    Reply to this comment

  9. Comment by jal posted on January 29th, 2010

    What about the number of http requests from the client side?

    Yes SPC reduces http requests to the ad server. But when someone visits
    the site they have 21 http requests to the server in order to download 20 banners to their browser…

    Francine, it sounds like you might have a solution for this? But I couldn’t quite follow what you did.

    I guess I’m trying to find a way to suture all the javascript invocations so there’s 1 javascript file– thereby resulting in 1 http request from the client side for all the ads.

    An external javascript file would also be cacheable further reducing load times.

    Anyone have any ideas?

    Reply to this comment

  10. Comment by Shawn posted on July 14th, 2010

    Thanks for this article. I know it’s old, but I didn’t actually spend much time in open-x, but found it useful for a project I did with quite a few ad’s on a single page, was scratching my head when checking in YSlow why the heck it was so slow, and what I could do to get rid of the HTTP requests.

    I would love a method that could combine js files, as that’s what I typically do via php and dynamically write a combined .js file on page load, only writes the file if the js source files were updated. But with open-x’s unique nature and my limited javascript ability. I’m not so sure how that can been done. This article though has helped a lot Thanks!

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on July 14th, 2010

      You are very welcome, thanks for stopping by and taking the time to leave a comment. I’m glad it was useful to you. OpenX still leaves a few things to be desired but all in all I feel it works well and when using the single page call method its not a horrific drain.

      I use a script on here (and most of my php sites) called phpspeedy that combines, minimizes and outputs a single file for js and css, it works well but it ignores the js for openx (you can select what ones to ignore if they don’t play well that way) if you look in the source on this site you can see the results, makes a significant difference in page speed.

      Reply to this comment

  11. Comment by Fernanda Thiesen (Twitter name: ) posted on August 7th, 2010

    thanks! that’s exactly what i needed! :D

    Reply to this comment

  12. Comment by vangel posted on August 12th, 2010

    thanks for this tip. However OpenX is still slow after awhile. I have sites with only a few pages views like 100-300 per hour, but openx fails miserably. No amount of tweaking, caching etc could help. Not to mention I am only having one ad spot per page.

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on August 12th, 2010

      If you are using the single page call method, with one ad spot per page and are still experiencing issues like that I would look at the server you are on. If you are on an overloaded shared host that could explain things, or perhaps something is not configured for optimal performance?

      As you can see I have 9 ad spots on my post pages and 7 showing on my home page and it loads fast. I do have a lot of server side optimization setup as well as every form of minification, page caching etc etc though.

      Reply to this comment

  13. Comment by idllc posted on November 26th, 2010

    works great except multiple copies of same ads show whereas they did not before. It appears the “don’t display same ad” option is ignored. We use this in order to alternate same ad in different postitions.

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on November 27th, 2010

      thats odd, I use the very same setting to prevent duplicate ads from the same campaign showing. I have never had an issue with it.

      Reply to this comment

  14. Comment by triathlonweek posted on February 7th, 2011


    I came across this article when searching for ways to speed up all the openx calls. I missed this method in the official docs. I did see a speed improvement since I was calling 4 different placements the old way.

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on February 7th, 2011

      You’re welcome. I know I searched high and low for a while because this information is definitely buried in the docs, glad this post is still useful :)

      Reply to this comment

  15. Comment by jimsflies posted on April 20th, 2011

    How do you set the auto refresh time using this method. I tried it, but it seems to not be rotating the ads.

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on April 23rd, 2011

      Rotating is handled with this method the same as others, keep in mind though that when you ad an additional banner to the system it will take some time for it to show due to caching within the system. I have seen it take 15-20 minutes for a new banner to start showing in the rotation.

      Reply to this comment

  16. Comment by Valentijn posted on June 14th, 2011

    Note also :
    spcjs.php?id=1&blockcampaign=1… or

    To hard code preventing double creatives

    Reply to this comment

  17. Comment by John (Twitter name: ) posted on September 12th, 2011

    I wanted to recommend OpenX to a customer this week, but they said they had heard it is too clunky and unreliable at the best of times. I see this string was started a couple of years ago, on the face of it how do people feel about it now?
    I’m actually after an affordable adserver with built-in CRM, you’d think they’d be plenty, but unfortunately not. Only big expensive solutions.
    Any feedback gratefully received.

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on September 13th, 2011

      Hi John,

      I have used OpenX on many client sites, the only down side I have found is that there is a bit of a learning curve involved to get someone to where they are completely comfortable administering it so they can get things just so… Once they get to that point though its pretty trouble free. I do highly recommend following best practices for optimizing its speed of delivery, the benefits are huge.

      As an example, I have it setup on a clients site that serves over 100K ad views per day and it’s been operating without a hiccup for over a year, I spent about 30 minutes going over how to create campaigns, add banners etc when I first set it up for them and have not had a question about it since. For the price I don’t think it can be beat.

      Reply to this comment

  18. Comment by miamiman posted on October 25th, 2011

    After three years of using Openx Hosted, I just have discovered the option of using Single Page Call.

    Anyway, per comment of idllc, I too am getting dupe banners when the option is clearly set to “Yes, don’t show.” Has anyone else found this?

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on October 25th, 2011

      If I recall correctly, you need to set that to no… it seems sort of backwards but when they ask you “don’t show same ad twice?” the answer they are looking for is “confirmation” of what the question says.

      Reply to this comment

Leave a Reply