Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's faster for including scripts, using CDN (Google) or storing them locally in website's root?

Tags:

html

jquery

cdn

What's faster for including scripts, using CDN (Google) or storing them locally in website's root?

like image 362
dzhi Avatar asked Apr 30 '10 16:04

dzhi


People also ask

Which is faster CDN or local?

CDNs deliver faster loading speeds for readers. Because this content is readily available, it is pushed to users faster than would be the case in a local website server.

Should I use jQuery CDN or local?

If you know what you want to use, use a local copy of jQuery, so you are not dependent on a third party. If you try out things with several libraries, use the CDN, because it's quicker and once you're done, use local copies for the reason mention before.

What are the advantages of using CDN in jQuery?

The advantages of using jQuery CDN are as follows: Decreasing the load on your website since the jQuery file will be loaded from a CDN and not from your website. The CDN will reduce the load on your website by loading the data from CDN and not directly from the website.

What is the best CDN for jQuery?

The best-performing CDN depends a bit on your needs. If you don't need HTTPS support, the fastest CDN is actually the official jQuery CDN, provided by Media Temple. Google's Libraries API CDN is a good second choice after that. If you need support for HTTPS, your best option is Google's Libraries API CDN.


1 Answers

If you mean the core jQuery libraries, use the google CDN for an internet-facing site (as opposed to an internal one).

The CDN has the following advantages you'll find hard to compete with:

  • More servers
  • The bandwidth (you don't pay for)
  • Geolocation (lower response time)
  • Redundancy
  • The optimized caching settings
  • Chance the user has already cached the file from there
  • Parallelized downloads, user can grab other content from your site at the same time

Though you can configure the cache headers just like they do, you probably can't serve the file faster. That being said, the library/CDN is only part of the puzzle. Miscellaneous plugins and code you have should also be minified, combined and served via gzip.

like image 197
Nick Craver Avatar answered Nov 05 '22 20:11

Nick Craver