views:

254

answers:

4

I am building a site which currently uses javascript from several sources:

Group 1: Google Maps API v3 (hosted by Google)
Group 2: jQuery & swfobject (hosted on Google CDN)
Group 3: Several jQuery plugins and non-jquery javascript files (hosted on my server)

I am using Justin Etheredge's tool SquishIt to combine and minify all the javascript files that are hosted on my server (group 3).

I am wondering if the site would 'feel' faster to users if I were to host the files in (group 2) locally so that they can be combined with all the other files in (group 3) and requiring only one HTTP request for groups 2 & 3. This would mean that I don't get the benefits of the Google CDN however.

Does anyone have any advice on this matter?

EDIT: Also, how would I come to a numbers based answer to this question? Is that possible?

+1  A: 

Using a CDN and combining / minifying serve different purposes. If you can use both.

  1. Combining Javascript files - reduces the number of http requests from a page
  2. Minifying Javacsript files - reduces file size
  3. Using a Cdn - improves latency.

If you can find a way to use both, its great

Though Combining Javascript files can turn into a more complex affair, than just minifying them.

You can use other CDNs if you want ( Amazon CloudFront )

Rishav Rastogi
+1  A: 

Probably won't make much of a difference.

The javascript files are small and static, and will be cached by users' browsers. By using the copy stored in the Google CDN your users might not even have to download the script the first time they visit your site.

By using the Google copy, though, you also introduce a dependency upon Google. If their servers go down (which they probably won't - at least not in the near future), your site might not function correctly.

Ben Herila
Thanks for you input.
jessegavin
+1  A: 

I think it depends on how likely it is that your users already have the google cdn file cached from visiting another site that uses the same asset.

My opinion is that it's better to use CDN since it's minified and somewhat likely the file doesn't need to be downloaded at all. Combine and minify everything else.

I'd be interested to know the global cache hit-miss ratio for those google cdn library files.

BC
Thanks for your answer. I think I will stick with the CDN.
jessegavin
+1  A: 

I'm combining, minifying (using closure) and using (akamai) CDN. But the most important tip for web performance are:

  1. use never expire cache
  2. async loading: you can use this script to load your externals js files

    (function() { setTimeout(function(){ var sc = document.createElement('script'); sc.type = 'text/javascript'; sc.async = true; sc.src = 'youfile'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(sc); },0); })();

Martin