Forum Moderators: martinibuster

Message Too Old, No Replies

hide adsense code to save bandwidth?

how i can do this?!?!?

         

Billy_Blue

12:22 am on Jan 19, 2006 (gmt 0)



i wanna save band width by not sending teh adsense code for every pageload how can i do this?

jtara

12:39 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<script src="somescript.js"></script>

topr8

12:55 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



respect! ... you are hardcore! approx 490 bytes per adblock!

JohnKelly

1:05 am on Jan 19, 2006 (gmt 0)

10+ Year Member



<script src="somescript.js"></script>

This may be against the TOS since it involves modifying the AdSense code. Better check with AdSense support first...

Chico_Loco

2:21 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And please let us know what they say.

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.

toomuch72

2:55 am on Jan 19, 2006 (gmt 0)

10+ Year Member



To prevent rewriting the adsense could This would be easy to do with php:

<?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.

btas2

3:03 am on Jan 19, 2006 (gmt 0)

10+ Year Member



The Javascript is against the TOS, or at least it was last year. I asked.

MrSpeed

3:33 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't get it. Bandwidth is what...30 cents/gig? Your worried about a few lines of javascript?

Billy_Blue

2:22 pm on Jan 19, 2006 (gmt 0)



30 cents gig?! where the hell you live? its like 50 bucks here

trillianjedi

2:25 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



where the hell you live?

It doesn't matter where you live when it comes to hosting.

My servers are 6,000 miles away from me ;-)

TJ

jfodale

2:30 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



I've got a related question:

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.

thegreatpretender

2:31 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



I think Billy_blue is just joking.

Chico_Loco

2:36 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

oddsod

2:37 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your fifty bucks is not the same as my fifty bucks is not the same as Rs 50.00 in India.

Leosghost

4:19 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I know of at least one french hoster who still charges one euro ( about $1.45 US at todays rates ) per "gig" when one goes over the allocation per server 500 gigs per month..and 145.oo euros about $220.oo US per burstable mps over the basic 2 included in their packs ..

Which is why I dont host where I buy my groceries ..;)

jomaxx

4:53 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

incrediBILL

5:39 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you can't afford the few bytes of AdSense code being downloaded then you probably can't afford to run that website in the first place as it's not profitable.

Find a different hosting company, maybe in another country even.

markus007

6:36 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Enable Gzip compression on your site for your dynamic pages and static pages and you will reduce your bandwidth by 80% or more. Most hosting providers won't let you do it if you are on shared hosting as it cuts into their profits. You will have to look around.

Mr_Fern

7:58 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



The few lines of javascript in adsense code are not going to kill your bandwidth. That's only a few bytes added on a page requested with adsense on it.

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.

toomuch72

8:23 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



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.

Mr_Fern

8:36 pm on Jan 19, 2006 (gmt 0)

10+ Year Member




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.