Forum Moderators: martinibuster
<paraphrase by moderator>
AdSense ad code cannot be placed in an external .js file as this would require the AdSense code be altered, which is against the AdSense terms and conditions
<paraphrase>
[edited by: Jenstar at 2:52 am (utc) on Feb. 11, 2005]
[edit reason] No email quotes as per TOS, thanks! [/edit]
You could always do it with a server side include, or depending what web server you're using, some other sort of server-based code. That way you wouldn't be altering google's code at all.
The Adsense program looks at the file it's been called from - if it's being called from:-
googleadsense.js
rather than
index.htm
it'll show generic site targeted ads rather than context sensitive ads (which is the whole point of Adsense anyway).
Oh and it slows down the ads showing, as the browser has to request the javascript file, read it, call the Google javascript etc.
[edited by: level80 at 2:50 am (utc) on Feb. 11, 2005]
Doing it with SSI includes is a supported alternative, although it's quite a bit more hassle, since SSI doesn't support absolute paths - so, for every page you'll have to use the correct relative path to the adsense include file.