Forgive me if there is an obvious answer to this question, but I haven\'t been able to find it. I am considering switching over to jQuery 2 and, although I\'m not concerned abou
A way to get the benefits of jQuery 2.0 while supporting IE 6, 7 and 8, is to use conditional comments:
<!--[if lt IE 9]><script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script><![endif]-->
<!--[if IE 9]><!--><script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script><!--<![endif]-->
<script>window.jQuery||document.write('<script src="jquery.js"><\/script>');</script>
jquery.js
, hosted on your server) is loaded.It looks like it just drops support for IE 6, 7 and 8 - you should be able to use:
HTML:
<!--[if lt IE 9]> <html data-browser="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
JS:
if( document.documentElement.getAttribute('data-browser') !== null ){
// not supported by jQuery 2.x
}
If you decide to support older browsers but still want the improvements the jQuery team have included in 2.x then you can use the 1.x version: http://jquery.com/download/
Update:
It's difficult/impractical to detect every browser that doesn't support jQuery, the reason is that jQuery is just a javascript library.
Different browsers and versions used to use different methods to do some basic things in javascript (like ajax), this means that some old browsers will support some features and won't support others. There isn't a straight forward this browser supports all features or this browser doesn't support any features test.
Rob W's suggestion is really good, serve the new version (2.x) to modern browsers and 1.x version (with legacy support) to old browsers.
Have a look at this article: Graceful degradation versus progressive enhancement and consider using the Modernizr library. This lets you to check which features the user's browser supports and allows you to write your applications to take full advantage of the latest advancements while still providing a good experience for users of older browsers.