I know that there is a Asynchronous method of using Google Analytics but is there something similar for adsense? I can't find one from my current searches - I was wondering whether there is a common trick I'm missing?
|
this does it:
see this blog item "Google Ads Async (asynchronous)" basically I've found a way to get the ad code to run truly async.. |
|||||||
|
|
Yes, there is a way - using iframes. We do asynchronous loading of ad content on one of our customer's sites. You first have to contact Google for support of their ads in iframes (which was not widely available back when we built that site). You can then use JavaScript to trigger the loading of the AdSense iframe content, which is what we do. The solution is really straight forward once you have Google's iframe support. Edit: Looks like - from the posts referenced by Virtuosi Media - this practice might not be welcome by Google... Edit 2:
This is the code we use in the iframe. Try it out to see if it works, maybe even without specifically asking Google for support. Removed
We fill all of our slots through adslot ids, so we are not seeing any PSAs. |
|||||||||||||
|
|
They don't currently offer the option, as far as I can see. Your best option, if it was allowed by the Google TOS, would have been to use a placeholder element and replace it dynamically with JavaScript after the page has loaded. However, it appears as if it may be against the TOS. See this thread for more details. |
|||
|
|
|
You can use a placeholder, call the Adsense code and then switch the placeholder with the ad. I'm using something like this on my site:
Google even recommends doing this when they say that you should have your most important ad position first in your HTML code. If you want to accomplish that you'll have to use JS or CSS to move less important ad units to the (visual) top of your page. But as far as I know AdSense already renders ads asynchronously. I've only very rarely seen it block pageloading. Not sure about this though. |
||||
|
|
|
Because google say "lets make the web faster" I change the above code to load the google ads only when they are visible. The code is work "as is" only for one google place ad, but I think you can easy modify it for more ads. The different with the other code are
Starting with the
I have test it and working with all browsers, I just use jQuery to be more safe that I am avoid browsers difficult. ps, I have make similar code to load the google plus, and the facebook and all that items that load with out reason the most of the times. |
||||
|
|
|
There is no further need to do this. The Google AdSense's show_ads.js now somewhat asynchronous. You can read more about the gory details on the official blog: Your Web, Half a Second Sooner There is no need to change ad code. |
|||
|
|
|
This asynchronous loading function is useful. I use it to pick the "perfect" size ad to obtain a full view in the available customer size window. As a result of post load heights and width adjustments, the definitive Adsene placeholders heights only become available after the body is fully loaded. Using this method enables me to display the "perfect" size Adsense ad or none if space is insufficient. |
||||
|
|