<!--[if lt IE 9]> <script src="jquery-1.9.0.js"></script> <![endif]--> <!--[if gte IE 9]><!--> <script src="jquery-2.0.0.js"><</script> <!--<![endif]-->No one expects old editions of IE to be supported forever and some will applaud the decision to abandon browsers which have caused development grief for many years. But the statement is surprising for several reasons. First, while IE6 and 7 usage has fallen to below 2%, they remain the browsers of choice for many large corporations, government departments and the Chinese. IE8 is likely to fall below 10% by 2013 but it’s the latest edition available to those on Windows XP. Almost one in three people use the OS and, while it’s dying, it’s lingering far longer than Microsoft anticipated. [The following section has been revised. Thanks to everyone who pointed out the error in the original code.] Second, conditional comments. Really? We’re still resorting to browser detection in 2013? That practice should have died out in 1999. Conditional comments were a temporary hack and have been dropped in IE10. JavaScript or server-side browser sniffing is no better. It also introduces the problem of having two forked code bases for the same library. Inevitably, there will be bugs and differences between 1.9 and 2.0 — especially as jQuery evolves beyond those editions. What do you do when your code works in one but not the other? Third: the primary reason developers use jQuery is to circumvent browser compatibility issues. The original purpose of jQuery, Prototype, Mootools, YUI and similar libraries was to provide a consistent set of objects and methods which abstracted the differing browser APIs. Wrappers are placed around features such as DOM selection and event delegation to smooth out implementation wrinkles. Today, the differences between modern browsers is negligible. Consider the DOM
querySelectorAll(CSS selector)
method; it’s supported everywhere (even in IE8) and will always be faster than jQuery’s $(CSS selector)
. Core JavaScript features such as traversal, manipulation, events and Ajax are usable everywhere. jQuery’s animations and effects can also be replaced by CSS3. jQuery 2.0 will still provide useful utilities and compatibility fixes but, without legacy IE support, there’s less reason to use it.
Fourth is the confusion the update will cause. Currently, developers can usually migrate to the latest version without breaking their scripts. It doesn’t matter how much publicity jQuery 2.0 receives, many people will think it’s “better” than version 1.9. They’ll upgrade then complain bitterly when their site fails in IE7.
Finally, if jQuery 1.9 works on all browsers, why bother with jQuery 2.0 which doesn’t? It might run a little faster but will that difference be noticeable? The library is already efficient and uses native APIs when they’re available.
I can understand the motivation behind this decision but 2013 feels a little premature. jQuery became popular because of its support for legacy browsers; the team shouldn’t abandon that policy too hastily.
Frequently Asked Questions about jQuery 2 and Internet Explorer Support
What is the main difference between jQuery 1.x and jQuery 2.x in terms of browser support?
The primary difference between jQuery 1.x and jQuery 2.x lies in their browser support. jQuery 1.x supports older browsers including Internet Explorer 6, 7, and 8, while jQuery 2.x has dropped the support for these older versions of IE. This means if you’re developing a website or application that needs to support these older browsers, you should use jQuery 1.x. However, if you’re sure that your users are on modern browsers, you can use jQuery 2.x, which is smaller and faster due to the dropped support for older browsers.
Can I use jQuery 2.x with Internet Explorer 8?
No, jQuery 2.x does not support Internet Explorer 8 and older versions. If you need to support IE8, you should use jQuery 1.x. However, if you’re developing for modern browsers only, jQuery 2.x is a better choice as it is faster and smaller due to the lack of support for older browsers.
What is the latest version of jQuery that supports Internet Explorer 8?
The latest version of jQuery that supports Internet Explorer 8 is jQuery 1.12.4. This version still provides support for older browsers including IE6, IE7, and IE8. If you’re developing a website or application that needs to support these older browsers, you should use this version of jQuery.
How can I check the version of jQuery used in my project?
You can check the version of jQuery used in your project by typing jQuery.fn.jquery
in your browser’s console. This will return the version of jQuery currently being used on the page.
What are the benefits of using jQuery 2.x over jQuery 1.x?
jQuery 2.x is smaller and faster than jQuery 1.x because it does not support older browsers like IE6, IE7, and IE8. This means if you’re developing for modern browsers only, jQuery 2.x can provide performance improvements over jQuery 1.x.
How can I upgrade from jQuery 1.x to jQuery 2.x?
To upgrade from jQuery 1.x to jQuery 2.x, you need to replace the jQuery 1.x script tag in your HTML with the jQuery 2.x script tag. However, before doing this, make sure that your website or application does not need to support IE6, IE7, or IE8, as jQuery 2.x does not support these browsers.
Can I use both jQuery 1.x and jQuery 2.x on the same page?
Yes, it is possible to use both jQuery 1.x and jQuery 2.x on the same page using jQuery’s noConflict method. However, this is generally not recommended as it can lead to confusion and potential conflicts.
What is the jQuery Migrate plugin and how can it help me?
The jQuery Migrate plugin is a tool that helps you to move from older versions of jQuery to newer ones. It detects and warns about deprecated features in your code, making it easier to upgrade your jQuery version.
What is the impact of not supporting older versions of Internet Explorer in jQuery 2.x?
By not supporting older versions of Internet Explorer, jQuery 2.x is able to be smaller and faster. However, this also means that websites or applications using jQuery 2.x will not work correctly in IE6, IE7, or IE8.
How can I ensure my website or application works correctly in older browsers when using jQuery 2.x?
If you need to support older browsers like IE6, IE7, or IE8, you should use jQuery 1.x. If you’re using jQuery 2.x, you can use tools like Modernizr to detect features and provide fallbacks for older browsers.
Craig is a freelance UK web consultant who built his first page for IE2.0 in 1995. Since that time he's been advocating standards, accessibility, and best-practice HTML5 techniques. He's created enterprise specifications, websites and online applications for companies and organisations including the UK Parliament, the European Parliament, the Department of Energy & Climate Change, Microsoft, and more. He's written more than 1,000 articles for SitePoint and you can find him @craigbuckler.