Why Adsense Can Slow Down Your Site


In order to use Google Adsense, you must insert a set of javascript code into your site. That javascript code has the potential of slowing down your page load times if you don't watch out.

The reason is this - in order for a browser to initially display an html page, it requires layout information. When you insert a reference to an external javascript file in your html, the contents of that file has the potential of changing the layout of your page. The browser will wait until the javascript has been downloaded before rendering the page just in case.

There are two known ways to resolve this problem, and a third which I plan on experimenting with in the very near future. The first and easiest method is to insert the code via an iframe. This has the additional benefit of providing you with a simple mechanism for updating all of the ads on your site by simply changing the code in the referenced iframe html file.

The second is an old SEO trick known as Source Ordered Content - you place the ad javascript code after any important elements on your page - in hopes that the text leading up to that element will be enough for your visitor to decide to stay long enough for the remainder of the page to load.

For some reason that I am completely oblivious to at the moment, I'm not too keen on the idea of an iframe. The Source Ordered Content trick actually has the drawback that it affects the potential placement of your ads, and depending on your layout can actually prevent more text from being rendred than you might expect.

The third method I'm going to experiment with is dynamic insertion of the ad code via javascript. In my html I would actually insert a reference element with id and class information that tells me where I want the ad. On my javascript init routine, I'll grab the ad-code directly from my server and dynamically insert it in the appropriate element. If it works (a big if), the appearance would be the same as always for a broadband user, but for a dialup user, the entire page would be loaded prior to the insertion of the ad code. I like advertisers and all, but I'm of the opinion that because the ads are peripheral to the information that the end user is seeking, it should not actually prevent the end user from seeing my site to begin with.

There have been at least 3 instances since I've been paying attention that Google has had extreme performance problems - poor enough that I'd wondered if my own ISP was having difficulty. The instances are few and far between, but alleviating a third party requirement from page viewing on your site is very important. You don't want your potential visitors to be turned away by page loading difficulties.




03-01-2007, 04:15 AM  
Brian
 
 
Re: Discussion: Why Adsense Can Slow Down Your Site

It's funny that you should have this post right now - RoadRunner is having network problems and I can't get to Google. You're site loads terribly slow, except for the discussion boards - which are lightning quick right now. Once adsense times out, your site loads up immediately.
  Reply With Quote


Talk About Why Adsense Can Slow Down Your Site