javascriptperformanceclient-sideopenxpage-load-time

How can we keep OpenX from blocking page load?


We're using OpenX to serve ads on a number of sites. If the OpenX server has problems, however, it blocks page loads on these sites. I'd rather have the sites fail gracefully, i.e. load the pages without the ads and fill them in when they become available.

We're using OpenX's single page call, and we're giving divs explicit size in CSS so they can be laid out without their contents, but still loading the script blocks page load. Are there other best practices for speeding up pages with OpenX?


Solution

  • OpenX has some documentation on how to make their tags load asynchronously: http://docs.openx.com/ad_server/adtagguide_synchjs_implementing_async.html

    I've tested it, and it works well in current Chrome/Firefox.

    It takes some manual tweaking of their ad code. Their example of how the ad tags should end up:

    <html>
    <head></head>
    
    <body>
    
    Some content here.
    
    Ad goes here.
    
    <!-- Preserve space while the rest of the page loads. -->
    
    <div id="placeholderId" style="width:728px;height:90px">
    
    <!-- Fallback mechanism to use if unable to load the script tag. -->
    
    <noscript>
    <iframe id="4cb4e94bd5bb6" name="4cb4e94bd5bb6"
     src="http://d.example.com/w/1.0/afr?auid=8&target=
    _blank&cb=INSERT_RANDOM_NUMBER_HERE"
     frameborder="0" scrolling="no" width="728"
     height="90">
    <a href="http://d.example.com/w/1.0/rc?cs=
    4cb4e94bd5bb6&cb=INSERT_RANDOM_NUMBER_HERE"
     target="_blank">
    <img src="http://d.example.com/w/1.0/ai?auid=8&cs=
    4cb4e94bd5bb6&cb=INSERT_RANDOM_NUMBER_HERE"
     border="0" alt=""></a></iframe>
    </noscript>
    </div>
    
    <!--Async ad request with multiple parameters.-->
    
    <script type="text/javascript">
        var OX_ads = OX_ads || [];
        OX_ads.push({
           "slot_id":"placeholderId",
           "auid":"8",
           "tid":"4",
           "tg":"_blank",
           "r":"http://redirect.clicks.to.here/landing.html",
           "rd":"120",
           "rm":"2",
           "imp_beacon":"HTML for client-side impression beacon",
           "fallback":"HTML for client-side fallback"
        });
    </script>
    
    <!-- Fetch the Tag Library -->
    
    <script type="text/javascript" src="http://d.example.com/w/1.0/jstag"></script>
    
    Some other content here.
    
    </body>
    </html>