Google Adsense blocks the page load

The Google Adsense code block

Everyone dealing with Google Adsense knows how it looks like as JavaScript code. When you register, apply and receive the code chunk, you receive actually an inline chunk of js describing the width and height of the code and the key, uniquely identifying the page ad and an included javascript file.

<script type="text/javascript"><!--
google_ad_client = "pub-9858850710257888";
/* 250x250, google ad 09-5-19 */
google_ad_slot = "0062396170";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.co/...">
</script>

Inline scripts and their behavior

The problem with the page load is that inline scripts included somewhere in the page, the case with adsense is just like that, blocks every page load until the script is executed. Of course when you’ve two or three ads somewhere in your page that causes huge delay of page load. Sometimes that may delay the page twice as much as if there were no ads from Google.

The workaround

The simple workaround is to place your ads <script> inline, included or both in a separate .html file and to include it as <iframe>. Such a solution gives the page the ability of render before the iframe is executed and the page load event is fired in an early stage.

<iframe src=”/path_to_the_banner.html”></iframe>

4 thoughts on “Google Adsense blocks the page load

  1. Hi,

    thanks for the nice tutorial. But I’ve a problem. Under IE, both 6 and 7, the iframe technique seems to be broken. I can’t manage it.
    Please help.

Leave a Reply

Your email address will not be published. Required fields are marked *