Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better to combine & minify javascript or use Google CDN?

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?

like image 200
jessegavin Avatar asked Sep 10 '25 21:09

jessegavin


1 Answers

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.

like image 198
BC. Avatar answered Sep 12 '25 12:09

BC.