I failed to load openx asynchronously follwing their documentation. It’s very disappointing especially when you read the fucking manual and it just doesn’t work. So I found a way to work around it. A bit dirty but works.
The normal openx setup is to reference the openx script in the head section. The script will issue a request to openx server to pull the ads content for the ad scripts in the body section to document.write. As you know this script will block the page load. But if you move the script to the bottom of the body, the document.write will fail.
1234567891011121314151617
<html><head><script type="text/javascript">varOA_zones={'top_banner':120}</script><!-- the script will issue a request to fetch the ads --><script type='text/javascript'src='http://ads.example.com/www/delivery/spcjs.php?id=7'></script></head><body><script type='text/javascript'>// openx document.write the ad contentOA_show('top_banner',true);</script></body></html>
What I did is basically override the OA_show function of openx and queue the function calls and release them when the time is right.
<html><head><script type="text/javascript">varadQueue=[];varOA_show=function(position,output){// queue the function call and create a place holderadQueue.push([position,output]);document.write("<div id='_"+position+"'></div>");}</script></head><body><divid="top_banner"><script type='text/javascript'>OA_show('top_banner',true);</script></div><script type="text/javascript">varOA_zones={'top_banner':120}</script><script type='text/javascript'src='http://ads.example.com/www/delivery/spcjs.php?id=7'></script><script type='text/javascript'>// excute function calls and display adswhile(adQueue.length>0){varargs=adQueue.shift();varad=OA_show(args[0],false);if(ad){$("#_"+args[0]).html(ad);}}</script></body></html>