CDN to host jQuery
Officially there are two ways of using jQuery:
- CDN Based Version - You can include jQuery library into your HTML code directly from Content Delivery Network (CDN).
- Local Installation - You can download jQuery library on your local machine and include it in your HTML code.
CDN Based Version
A CDN (Content Delivery Network or Content Distribution Network) is a network of proxy servers globally distributed throughout multiple geographic locations where end users can access cached content. Several tech giants ( Google , Microsoft etc.) offer copies of jQuery libraries hosted on their CDN. Using a CDN can offers better performance of your jQuery (and website as a whole). In order to load a hosted jQuery library, copy and paste the HTML code for that library (shown below) in your HTML page.
FullSource using Google CDN
CDN for jQuery has many advantages. The major advantage is the loading speed because CDN is made for faster loading. So jQuery library gets downloaded very fast from CDN (Content Delivery Network) , in this case making your web-pages to load faster by a few milliseconds .
There are two versions of jQuery libraries accessible for downloading from websites:
- Production version - this is for your live website because it has been minified and compressed.
- Development version - this is for testing and development (uncompressed and readable code).
The uncompressed version is preferable during programming or debugging; the compressed version saves bandwidth and boost performance in production level. Both versions can be downloaded from jQuery.com web-site.
However, it's normally a better idea to hold the file name the same as when you downloaded it from CDN websites, as it contains the jQuery version . Also, most web-sites have a different directories for their JS files so you'll need to use the full-path in this case.