Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
We've seen that it's simple to download jQuery so that you have a copy of the file on your site to send to your users. But there is a better way: let somebody else do it. Several companies, including Google and Microsoft, allow you to link to jQuery, and some other common libraries, and get that file directly from their servers. And they don't just have one server but typically a bunch of geographically distributed servers with load balancing and failover, all in a Content Distribution Network, or CDN, so it's almost always faster for the user to get it from one of their servers than from your server.
So if that user then goes to another site and retrieves some HTML and CSS that's also using that same CDN and that same path, the browser will realize, hey, I've already got a copy of that jQuery file. I don't need to download it at all. So I've talked about jQuery here, as it's the most common, but if you want to know what other libraries are available, we'll get in more details, go to code.google.com/apis/libraries.
Now one more thing: you'll see that Google makes this path available as https here. That's where it showing up in this list. In fact, it is available as both http and https paths. The main reason it needs to be available as an https address is so you can use it from an encrypted page without the browser complaining that you're using an unencrypted asset on that page. There really is no other benefit to encrypting jQuery; everybody knows what it is.
But if your site needs to link to jQuery from pages at a variety of http and https addresses, one shortcut is that in your link to that file you actually just remove the protocol from the link, so you remove http: or https: and just have the two forward slashes. It looks a little strange, but that will just use whatever protocol the current page is using. And that's all there is to it. The only place I wouldn't use Google's CDN is if I was developing a purely internal intranet site where my users are literally in the same building as the web server.
But otherwise, I highly recommend a CDN as your default way of linking to a library like jQuery. There really are no downsides here.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 93555 Viewers
82 Video lessons · 104388 Viewers
71 Video lessons · 76530 Viewers
56 Video lessons · 107855 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.