That'll work fine if you are just using plain ole JQuery selectors and a limited number of functions, but if you are using any plugins and/or you are using functions which are no longer supported/broken/removed in 2.x then you'll not only need this statement but lots more testing surrounding the differences between the two. In the area of plugins you could be really screwed if you are dependent on a plugin that is broken in 2.x.
Like others have stated I'm sticking with 1.8.whatever for now (foreseeable future)
depends on your level of control over the entire project I guess, but if it were me I'd choose not to use that plugin over choosing to use an old version of the entire framework.
If I were you I'd choose to use plugins that are actively maintained by their developers. They have had more than enough time to plan for jQuery 1.9 (and 2.0). For a lighbox, try colorbox or fancybox.
In most cases you should just use one or the other IMO. The only benefit to this approach I can see is giving IE9+ (and good browsers) a smaller file size. Weigh that against the ugly/hacky conditional comment syntax, addtional cruft and complexity, and having to test that it works the same with both versions of jQuery, and I'd rather JUST use 1.9 in situations where I need to support IE<=8.
if you want to support older IE versions, you pretty much have to use conditional comments anyway.
I don't necessarily agree with this - especially if you aren't trying to support IE6. You can do quite a bit using code that just works in all browsers. I very rarely have to use any browser specific-code - and I do this stuff for a living.
And I think "completely incompatible" is a pretty big exaggeration.
Very true, however, this will be a micro-optimization at the expense of clean code. You're only shaving 4kb off the gzipped/minified code. Replace jQuery with Zepto and you'll cut ~20kb.
Ok, so from what I've read, you can set conditions for IE 9, and IE 10 will read that, but you can't set conditions specifically for IE 10. Is that correct?
See because MS have literally completely stopped making errors in their browser there is no longer any possible scenario in which you would need to target IE10 so best thing is to
9
u/Fabien4 Apr 18 '13
According to an earlier entry, we're supposed to use the following code for maximum compatibility, right?