Welcome to WebmasterWorld Guest from 184.108.40.206
I am not sure if it is against TOS, but I am not modifying the code except that I am using a document.write(..) to display the adsense code...
that would only impact the first page
True. Depends on how much you're willing to let the time-lag impact on your first view. I'd rather have my one-view-bouncers view and click on my ad to leave the site than going back to SERPs.
Done this way, the Adsense file gets cached, speeding up your load time. I put the tag early in the mark-up, then float it with CSS into position on about 150 webpages, using 6 different versions. But it is the slowest component of my page since it comes from a remote server.
Why not simply put it in an include file as I do?
That's exactly what we're recommending.
Depends on how much you're willing to let the time-lag impact on your first view.
When you include the code at the beginning of the page it's pre-loaded so there's no perceived delay once the page is displayed except the time it takes AdSense itself to execute which as keyplyr noted it already slow.
I don't think it's worth the effort myself because there's not enough lines of code in the AdSense part we install to really impact page load and you would be better off implementing gzip page compression if you don't already have it to improve load speed.
No need use document.write, it's in an include file.
Wrap it in a function call like "func AdSenseSkyScraper()" and then just call the function later in the code.
This is a non-issue.
Including it in JS
1. Cached, Gzipped
2. Served only once to the visitors
1. Slow for the first time
Including it on server side
1. This approach is clearly not against TOS
1. Served for every page making the size of the page large
2. Including the file on the server side makes an additional cpu cycle
Am i missing something here?
Simply place your Google code into an include file (i.e. .html, .txt, .php, .asp) and use the appropriate code within your HTML.
PHP: <?php include("google-stuff.txt/php/html"); ?>
ASP: <!--#include file="google-stuff.txt/asp/html"-->
Minimize DNS lookups
The domains of the following URLs only serve one resource each. If possible, avoid the extra DNS lookups by serving these resources from existing domains:
Also has anyone thought of the fact that the browser caches show_ads.js even when loading from google's servers? Surely its not fetching it everytime its called on the multitude of pages on the web! I just checked and on subsequent access google sends a 304 not modified header and the browser simply loads the file from cache.