Category Archives: micro tutorial

Google Adsense, iframes and IE

What a lovely combination

Recently I wrote an article about the Google Adsense problem with page load blocking and than the solution was simple and elegant. You must put your ad in a separate .html file and to include it into your page with an iframe. That gives the page the ability to “breath” and to load faster.

You can see the entire article here.

When everything’s OK, wait for the IE

Yes as usual every browser loaded the iframe correclty, except … Continue reading Google Adsense, iframes and IE →

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>

Zend Framework and multiple db connections

The use case

Recently we (Petar Atanasov and me) were working on a Zend Framework project, which requires more than one database connections. The framework as a typical MVC architecture does not allow that functionality forcing the user to use one single connections. However there is the setDefaultAdapter in ZF which is enough to think about switching the default adapter between the different connections.

The detailed tutorial how to make it work you can find on my colleague’s blog here.