Forum Moderators: martinibuster
It's worth mentioning that technically you are uping the actual bandwidth with this method, plus an additional request needs to be made (at least the first time) (SCRIPT line + source code + additional hit for .js file) - so on the first pageview, the page will be SLOWER to load than if the code were pasted directly into the source code.
HOWEVER, the benefit of this method is that the browser will LIKELY (not gauranteed) cache the source code of the .js file after the first pageview, and thus load it from cache upon pageviews thereafter.
SO - this is technically only beneficial if your users view at least 2 pages on average. Of course, if your average pageviews per visitor is less than 2 then you have other, more challenging issues.
<?while ($oktoshow=='yes'){?>
put the adsense code here
<?}?>
On the other hand if you wanna stick with javascript maybe put the adsense code in a function(warning because the adsense code includes the <script> and</script> this may not work) and this still may be a violation of TOS since you are calling the adsense script from a different location then you actually pasted it. That sounds like a manipulation to me.
<script type="text/javascript">
function showadsense()
{
adsense code
}
</script>
Edit: I'm a very part time Javascripter so don't trust me on the code I posted do your research.
Are webmasters allowed to use SSI or PHP includes to include the AdSense javascript on pages? If we can't, is there another way to do this? I've only got 100 pages of content, tiny compared to most of you, but I still don't want to edit every page in case I need to pull AdSense off or change it.
30 cents gig?! where the hell you live? its like 50 bucks here
I used to work with a company in the UK, and with the hosting company they were using they were charging 5pence/meg over the alloted amount - we went over it by a few gigs one month and quickly found out that they weren't kidding about it. That was about 3 or 4 years ago - so if you're using a host that still charges that, then you're being ripped off, big time.
Are webmasters allowed to use SSI or PHP includes to include the AdSense javascript on pages?
Yes, you are allowed, since technically the source code isn't being modified - it's just being included "indirectly" through the SSI, but in the source code of the resulting HTML page, the code is unmodified.
Which is why I dont host where I buy my groceries ..;)
Markus' solution is optimal, although if you don't have large HTML files, you're not in any real danger.
You should be concerned with the file sizes of your images and multimedia.
With respect to the PHP comments above: PHP is fine to use with AdSense but it will have no effect on bandwidth, which is what the OP wanted to optimize. PHP operates server-side and is invisible to the end user, including spiders. Same with SSI.
Actually the way php works is it sends the final results of a page execute over the net(the bandwidth). If you tell a portion of the page not display it will never even be sent off the server. Do a "view source" on a php page and you will see that the actual .php file and what is displayed is completely different. So if you prevent the adsense code from displaying server side it SHOULD not be sent off the server at all.
Now, for all I know, I could be wrong? perhaps how hosting companies work is whatever is EXECUTED is what they consider bandwidth. The amounts have been so minute that I have never really looked into this.
With respect to the PHP comments above: PHP is fine to use with AdSense but it will have no effect on bandwidth, which is what the OP wanted to optimize. PHP operates server-side and is invisible to the end user, including spiders. Same with SSI.Actually the way php works is it sends the final results of a page execute over the net(the bandwidth). If you tell a portion of the page not display it will never even be sent off the server. Do a "view source" on a php page and you will see that the actual .php file and what is displayed is completely different. So if you prevent the adsense code from displaying server side it SHOULD not be sent off the server at all.
Now, for all I know, I could be wrong? perhaps how hosting companies work is whatever is EXECUTED is what they consider bandwidth. The amounts have been so minute that I have never really looked into this.
You are correct that only the output of the PHP script will be counted as bandwidth, but that was the point of jomaxx. Even if you use PHP to place your adsense code, the adsense code is still part of the output, thus it will still be counted as bandwidth, and doesn't solve Billy's problem.