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

HTML jQuery Basics (2014) Introduction to jQuery Ways to Include jQuery in a Project

Don Shipley
Don Shipley
19,488 Points

JQuery

In the video it shows how to copy the CDN and paste it in your HTML. On the video the link has Http:// yet the new JQuery site the link is missing the Http;. using notepad ++ and Google Chrome the link does not work unless you add the Http: am I doing something wrong when copying and pasting the link?

Video shows on JQuery site <script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>

http://jquery.com/download/ shows <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

6 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hey Don,

This question comes up a bit in the forum so I thought I'd make a video on explaining the pitfalls of including jQuery in modern web development. The URLs that start with // are known as Protocol Relative URLs or sometimes Protocol-less URLs.

Hope this clarifies things for you and others.

Regards,
Andrew

This is because the browser see's "//code.jquery.com/jquery-1.11.0.min.js" as a link to a file on your system, if you are wanting to copy and paste the jquery file into your filesystem for use on your site, use the http:// infront like this: "http://code.jquery.com/jquery-1.11.0.min.js" copy the code and paste it into a file called "jquery-1.11.0.min.js" granted it can be called whatever you want it to be called.

The above jquery file example was just the first link that I came to so please pick the version that you require. 2.0.x is available too although does ignore some of the older browsers and sometimes best to stick to 1.10.x generally.

You could also drop this into your page and load from a CDN: <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

Hope this helps.

Just to add because it might be useful to some: Another pitfall which I can think of but occurs much rarer is when you are creating content for a company which accesses the internet site via a proxy, in few cases the library load time of the given CDN increases significantly. This error can be nailed down very difficult as it usually occurs at random, but removing the CDN and including the file on the server solves the problem.

David Endersby
David Endersby
24,915 Points

Thanks Andrew . Very insightful. :-)

Don Shipley
Don Shipley
19,488 Points

Thank you Andrew, I should have realized it was looking for the file on my machine. I do have wamp on my machine so rather than opening the html from notepad++ I opened it up from my localhost removing the http: . Works fine, also see your point on the https:

Aamnah Akram
Aamnah Akram
17,549 Points

Faced the same issue with Bootstrap CDN links, now i know why that happened. Thanks Andrew for the video, i feel like i know a secret.

Thanks, Andrew. That video solved my problem. I'd like to suggest that Treehouse append this information to the JQuery Basics course. It could really help a lot of people.