Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Understanding and installing jQuery

From: JavaScript and AJAX

Video: Understanding and installing jQuery

jQuery is a framework that fixes compatibility issues that happen with JavaScript in older browsers. The library also gives you a lot of additional tools for working with the DOM. One of my favorite features of the framework is how easy it makes it to work with AJAX. So let's go ahead and take a look at some of the options you have for installing jQuery. So there's two ways you can include jQuery into your projects. You can download a copy or use it from a CDN. A CDN is a content delivery network. You can see links to those if you click on the Download tab right here and then look over here to the left.

Understanding and installing jQuery

jQuery is a framework that fixes compatibility issues that happen with JavaScript in older browsers. The library also gives you a lot of additional tools for working with the DOM. One of my favorite features of the framework is how easy it makes it to work with AJAX. So let's go ahead and take a look at some of the options you have for installing jQuery. So there's two ways you can include jQuery into your projects. You can download a copy or use it from a CDN. A CDN is a content delivery network. You can see links to those if you click on the Download tab right here and then look over here to the left.

Those are links to the most popular CDN libraries that have jQuery. You can also try cdnjs.com; that has copies of a lot of libraries, including jQuery. So the advantage of using a CDN is that if a browser has loaded your library from a CDN when you visited some other website, it may already be cached in your browser when it comes to your site, so your page will load a lot faster. The disadvantage is that CDNs will only work while you have a live connection to the Internet. If you're working with a local copy or maybe flying around on an airplane or coding where your connection is spotty, then the CDN is not going to load at all and none of your JavaScript will work.

So you load them both into your code in pretty much the same way. So let's go ahead and go to the front of the jQuery website and click on this Download link. Now, before you do that, see that there's two options here. You have the option of downloading a Production version or a Development version. Now, the Development version has a copy of all the code with comments that's super easy to read, but it's obviously a lot bigger. Whereas the Production is minified and Gzipped, which means that it's compressed, it has no comments, a lot of the variable names have been changed so that they're smaller, and it's really pretty impossible to read.

You should use the Development version if you're going to be editing something about the jQuery JavaScript code; otherwise, just use the Production version, and that's what I'm going to do. So I'll click on Download jQuery. Sometimes you see this kind of code right here, which is essentially the JavaScript code for jQuery. I told you the Production version was hard to read, and I wasn't kidding. Now, to save this I'm going to go to the File menu-- I'm using Safari right now--and I'm going to select Save As. And here I'm just going to rename this jquery.js and I'll just save it on the Desktop.

I want to make sure that from this Format menu, I choose Page Source. Make sure it's not in Web Archive. So I'll select that, hit Save, and now that saves it into our desktop, so I'm going to switch there. And what I need to do now is copy this into my server, so I'll copy that just by dragging it. I'm using Transmit as my FTP program, so there it is. It's already on my server. And now what I want to do is select the files that I need and open them up in my editor. So I've got all these files opened up in my editor.

There's the jquery.js library. I really don't need to see it, so I'm just going to close it up. What I need to do to insert it is go to my index.html file and then load it up just like I would any other script. I want to make sure that I load it up before my script.js, because that's where I'm going to be putting my regular JavaScript and I want to make sure that the library is there before my other scripts load. So I'll do a script tag, and as the source I'll just type in jquery.js. I don't need this part. Now, the only difference between this and loading it from a CDN is that if you were to load this from a content delivery network, you'd want to get the URL of the library and just copy that from here and paste it into your script tag.

But I'm not going to do that because I'm just using a local copy. So save it and now jQuery will load into my application, and it's ready for me to use. Loading up jQuery is normally done using one of the CDNs when you're in production, but keep in mind that if you're going to be offline and developing, then downloading a copy is a super-smart idea. One more thing: you should always load jQuery before your regular JS file. That way all the power of the framework is going to be available when you write your scripts.

Show transcript

This video is part of

Image for JavaScript and AJAX
JavaScript and AJAX

21 video lessons · 19059 viewers

Ray Villalobos
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed JavaScript and AJAX.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.