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 jQuery Basics (2014) Introduction to jQuery Ways to Include jQuery in a Project

Mohammed Jammeh
Mohammed Jammeh
37,463 Points

Confused about the jQuery CDN Download

In the 'Ways to Include jQuery' video, Andrew suggests going to https://jquery.com/download/ to download the jQuery file by including the link at the bottom of a HTML file.

However, I am quite confused. It seems like this page or download source has been updated and there are many other links. Which links do you recommend is the most suitable at the moment?

Mars Epaecap
Mars Epaecap
5,110 Points

I'm on the same page as you, I went to https://code.jquery.com/ and picked minified version of what seemed to be the latest (jQuery 3.x at the time of writing this) which has

<script
              src="https://code.jquery.com/jquery-3.0.0.min.js"
              integrity="sha256-JmvOoLtYsmqlsWxa7mDSLMwa6dZ9rrIdtrrVYRnDRH0="
              crossorigin="anonymous"></script>

the code in my Index.html file now looks like this:

<!DOCTYPE html>
<html>
<head>
    <title>Take Evasive Action</title>
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">



</head>
<body>
  <p class="warning">
    <span>It's A Trap!</span>
  </p>
  <div class="image">
    <img src="img/ackbar.gif" />
  </div>
    <script src="http://code.jquery.com/jquery-3.0.0.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/app.js" type="text/javascript" charset="utf-8"></script>


</body>
</html>

3 Answers

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 27,671 Points

Hey Mohammed,

I'll recommend something different. Rather than download any files and host them yourself, you can use a CDN to do the heavy lifting for you. All you need to do is include a specific <script> tag in your HTML.

Go to http://code.jquery.com/ and select the version of jQuery that best suits your needs. It will most likely be the latest minified version (which doesn't support <IE9). You'll then copy the presented code snippet and paste that above any scripts that require the library. Here is the current snippet:

<script  src="http://code.jquery.com/jquery-3.0.0.min.js"  integrity="sha256-JmvOoLtYsmqlsWxa7mDSLMwa6dZ9rrIdtrrVYRnDRH0="  crossorigin="anonymous"></script>

Uncompressed: Developer friendly code that is nicely formatted and includes comments

Minified: Production ready with all formatting/white-space/comments stripped

Mohammed Jammeh
Mohammed Jammeh
37,463 Points

Oh okay, I understand now. It's working as well. Thanks so much guys, appreciate it :)

Anas AlHariri
Anas AlHariri
8,776 Points

I'm using this. Is it ok?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>