Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

What does it mean to "host your own jQuery"?

Near the end of the video: https://teamtreehouse.com/library/optimize-javascript

It is mentioned that you can host your own jQuery; what's the meaning of it and what benefits does it give?

2 Answers

jQuery, though powerful, is just a JavaScript file that you reference from your web page or app. It is often hosted on CDNs that you can link to. However, you can also download the jQuery file and store it with all of your other website assets. This would be the "self hosted" option. Simply put, you upload the file with the rest of your website and link to that location from your page or app.

More information available at https://jquery.com/download/

Isn't the CDN option better since it is supported by multiple servers, while if you self-host it, your location is the only server? Is there any benefits in self-hosting it?

Can be better to use a CDN, yes. Benefit of self hosting is that you have complete control over the library and the version you're using and you're not dependent on any third party for performance or maintenance.

Benefit of self hosting is that you have complete control over the library

So I can have complete control of the jQuery library? What does that mean? How does that differ from hosting it from the CDN option?

You maintain the version you want to use at all times. Depending on your CDN, they may eventually stop supporting/hosting a particular library/plugin you're using. Not usually an issue if you keep everything current on your own, but not everyone is as diligent about that as others. It also helps reduce variables when developing/maintaining very large sites and/or large teams. Reducing the variables that could contribute to outages or code inconsistencies can be helpful there. Different solutions for different problems. I'd say most of the time you'd be fine using external CDNs.

I believe that means to include the jQuery file within your web-app. As jQuery can be both requested with the jQuery CDN simply including a source into your HTML, or it can be included and within it's own file on your project.

Isn't the CDN option better since it is supported by multiple servers, while if you self-host it, your location is the only server? Is there any benefits in self-hosting it?