Better to combine & minify javascript or use Google CDN? Better to combine & minify javascript or use Google CDN? javascript javascript

Better to combine & minify javascript or use Google CDN?


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.


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 )


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.