Introduction to jQuery 2.0S2C Home « Introduction to jQuery 2.0

So what's the difference between the jQuery 1.x series and the jQuery 2.x series? Well the API libraries are the same but the jQuery 2.x series JavaScript files are smaller and faster. The caveat being that the jQuery 2.x series doesn't support the older Internet Explorer 6, 7, and 8 browsers along with all the issues that impact those browsers.

As the actual methods, properties and objects in the jQuery 2.x series are exactly the same as those in the jQuery 1.x series we won't repeat all the lessons and references here. So you can happily use the jQuery 1.10 section of the site for gaining all the knowledge required to use the jQuery 2.x series

Ok, the first thing we need to do is download the latest version of the jQuery 2.x series from the jQuery site. At the time of writing, the current release is version 2.0.2.

You have the choice of a minified version, which has a file size of just 81.5 kilobytes and should be used for your production code. Also available is an uncompressed version, which has a file size of 237 kilobytes and can be used in development and investigated to see how jQuery works. Right-click the link you require and select "Save Link As..." from the menu to save the file of you choice.

With jQuery downloaded place the file in a directory of your choosing for use in your programs. The following code snippet is an example of importing the minified version of jQuery into a HTML file and assumes the file exists in the current directory.

<script type="text/javascript" src="jquery-2.0.2.min.js"></script>

The links to the HTML section of the site below give a full explanation of URLs and a discussion on importing files respectively. The lessons are helpful if you are unsure of where to place your files and how to access them from within your web pages.

HTML Intermediate Lesson 5 - More About Links
HTML Advanced Lesson 1 - Importing CSS and JavaScript

Should I Use The jQuery 2.x Series?

This depends if any of the users on your sites are still using Internet Explorer 6, 7, and 8. If they are then you're probably better sticking to the jQuery 1.x series whilst these browsers still have audiences. If you are happy using conditional comments in your HTML then you can get the best of both worlds and accomodate all your users. The conditional comments below will send all Internet Explorer 6, 7, and 8 users to the jQuery 1.x series, whilst users of newer browsers will get the jQuery 2.x series.

<!--[if lt IE 9]>
    <script src="jquery-1.10.1.min.js"></script>
<!--[if gte IE 9]><!-->
    <script src="jquery-2.0.2.min.js"></script>

Using the above conditional comments you just need to ensure you have both of the relevant jQuery files available.

Lesson 1 Complete

That's about it for the jQuery 2.0 section of the site as browsers stand at the moment.

go to home page Homepage go to top of page Top