Forum Moderators: martinibuster

Message Too Old, No Replies

Hosting scripts externally: AdSense, search & analytics

         

wolfadeus

4:50 pm on Jan 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure if this is the right forum to post this question, but this is my problem: I am using several javascripts (tools and gadgets) that I host in a separate folder; in the HTML of the page that uses the script, I just add two or three lines of code that tell the browser where to look for the script.

Now, a fair chunk of code on every page comes from Google AdSense, the Google Search tool and - to a lesser degree - the Google Analytics code. Is there a way to host all three scripts centrally? If so, this would be tremendously useful to decrease loading times and traffic, as the code is the same on essentially all pages of my site and could be saved in the cache of most browsers.

Thanks for your advice!

W.

wolfadeus

6:31 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For a clarification: This is the code that I use for implementing an external script:

<script type="text/javascript" src="../javascripts/widget.js">
</script>

I was wondering if I could use similar ways to avoid the repetition of AdSense, G-Analytics and Google Search-Box code on every single page.

mayest

7:23 pm on Jan 15, 2009 (gmt 0)

10+ Year Member



Strange that nobody has responded. Is there some reason that you think that you aren't supposed to do this?

I do something similar to a server-side include in my CMS, for all of the above services.

jetteroheller

7:28 pm on Jan 15, 2009 (gmt 0)

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



This is an interesting theme.

I just implemented to deliver my javascript compressed.

This is to optimize page load time.

I thought also to deliver the html pages compressed,
but this is not possible, because I insert the AdSense code by SSI.

What the SSI does, could also do a javascript.

This would be an additional speed up of the load time.

Now

load html page uncompressed and after SSI is performed
load AdSense javascripts
load javascript from search box
load own compressed javascript
load Google Analytics

What would speed up the load time

load compressed html page
load own compressed javascript (including AdSense code, javascript for search box)

load AdSense javascripts
load Google Analytics

jetteroheller

8:07 pm on Jan 15, 2009 (gmt 0)

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



Just a study from a page:

16166 bytes html
13100 bytes AdSense code, AdSense search box, Analytics code removed

(it's assumed this would be inserted by the javascript)

3755 bytes Gun Zip compressed

The javascript would be a little bit longer, but this does not matter, because I load the javascript at the end of the page. Rendering the page can be started before.

Also, the code transfered to the javascript is good compressable.

wolfadeus

8:56 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think I have come across any sites where SSIs or external hosting were used for AdSense, Search Box and Analytics code. Is there a reason for including the code on every page?

jetteroheller

9:00 pm on Jan 15, 2009 (gmt 0)

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



I don't think I have come across any sites where SSIs or external hosting were used for AdSense

You can not see, if SSI is used or not.

tha page just looks like the page.

wolfadeus

9:03 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"I thought also to deliver the html pages compressed,
but this is not possible, because I insert the AdSense code by SSI."

Jetteroheller, how are you doing this? Do you use commands like that:

<!--#include file="adsensewidget.js" -->

wolfadeus

9:04 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry for my basic questions, but I have no experience with SSI at all. Does is just include the external HTML if you view the source and is thus not noticable?

wolfadeus

9:09 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, caught up with some very general information from self-HTML; question: If I include external HTML-snippets using an SSI, do I have to rename my widget.htm files into widget.shtml files or does that depend on my server (which is as I understand it)?

jetteroheller

9:17 pm on Jan 15, 2009 (gmt 0)

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



OK, caught up with some very general information from self-HTML; question: If I include external HTML-snippets using an SSI, do I have to rename my widget.htm files into widget.shtml files or does that depend on my server (which is as I understand it)?

No! Just write in Your .htaccess

AddType text/x-server-parsed-html htm

wolfadeus

9:30 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks. So far, I had no .htaccess

So I use notepad to generate a .htaccess that includes that single line of code (AddType text/x-server-parsed-html htm) and put it into my root directory and then the server can work with SSIs?

mayest

10:54 pm on Jan 15, 2009 (gmt 0)

10+ Year Member



If you are using an Apache server, I think that jetteroheller's solution should work. Just create a plain text file named .htaccess with that line in it and upload to the root directory your server.

If you have any problems getting it to work, the Apache forum [webmasterworld.com] is a great resource.

IanCP

1:16 am on Jan 16, 2009 (gmt 0)

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



I don't think I have come across any sites where SSIs or external hosting were used for AdSense, Search Box and Analytics code. Is there a reason for including the code on every page?

All mine are! I shudder to think what life would be like without it.