r/webdev • u/rnvk • Apr 18 '13
jQuery 2.0 Released
http://blog.jquery.com/2013/04/18/jquery-2-0-released/9
u/Fabien4 Apr 18 '13
According to an earlier entry, we're supposed to use the following code for maximum compatibility, right?
<!--[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]-->1
u/munkyxtc Apr 19 '13
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)
0
1
u/kylegetsspam Apr 19 '13
I wouldn't even go as far as 1.9 since even that has broken some plugins (this one, for instance).
9
u/danvasquez29 Apr 19 '13
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.
1
u/zzzwwwdev Apr 19 '13
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.
1
u/zzzwwwdev Apr 19 '13
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.
2
u/Fabien4 Apr 19 '13
Weigh that against the ugly/hacky conditional comment syntax,
If you want to support older IE versions, you pretty much have to use conditional comments anyway.
and having to test that it works the same with both versions of jQuery,
You have to test your features on each IE version you support anyway. IE6, IE7, IE8 and IE9 are four completely incompatible browsers.
3
u/zzzwwwdev Apr 19 '13
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.
1
Apr 20 '13
Smaller file size is good when developing for mobile. Remember, not everyone has an unlimited data plan. The more you can reduce overhead, the better.
1
u/zzzwwwdev Apr 22 '13
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.
0
Apr 19 '13
How does this work when Microsoft said that IE 10 doesn't support conditional statements anymore?
9
u/Fabien4 Apr 19 '13
My understanding is that IE10 will act just like real browsers, and thus load jQuery 2.
The problem will be with jQuery 3, when IE10 is still heavily used but more than 5 years behind everything else.
1
Apr 19 '13
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?
4
u/Fabien4 Apr 19 '13
From what I've heard, IE10 will act like a browser. So, if you set a condition for IE9, IE10 will ignore it.
When Firefox sees the code above, it will remove the comments, i.e. the things between
<!--and-->. That leaves:<script src="jquery-2.0.0.js"></script>I assume IE10 will do the same.
IE9 will skip the
[if lt IE 9]conditional comment but accept the[if gte IE 9]conditional comment, leaving:<script src="jquery-2.0.0.js"></script>(Note that actually, one could write
[if IE 9]instead of[if gte IE 9], and it'll do the same thing.)IE8 will accept the
[if lt IE 9]conditional comment but skip the[if gte IE 9]conditional comment, leaving:<script src="jquery-1.9.0.js"></script>-1
u/teh_ Apr 19 '13
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
4
u/zzzwwwdev Apr 19 '13
As should be clear from the linked article and comments, jQuery2 abandons older versions of IE that, in many (most) cases in our day-to-day website development we cannot yet ignore. Thats why the 1.9x line will be maintained. There are cases where jQuery is fine to use NOW, and I for one am excited that they put it out there. If nothing else, it keeps us looking to (and planning for) the future.
3
1
u/MattBD Apr 19 '13
A lot of my work is with Phonegap apps, so I guess I'm lucky in that I'll be able to adopt jQuery 2.0 immediately for those. For web apps, though, I'll probably stick with 1.9 for now.
1
u/Guard01 Apr 18 '13
Looks like I'll be using 1.8.xx
1
u/WoollyMittens Apr 19 '13
Do you think that Zepto.js would be enough for most simpler projects? I've been worried that jQuery is puffing up like a giant souflé.
4
u/Fabien4 Apr 19 '13
Isn't the whole point of jQuery 2.0 to reduce the cruft?
0
Apr 19 '13
[deleted]
2
u/danvasquez29 Apr 19 '13
as a sysadmin, I encourage it. At this point, breaking my clients' favorite sites and crippling their available services is either going to be the last straw for them to finally migrate from XP, or the last straw for me that makes me realize they're hopeless.
At a minimum, it gives people like me a reason to forcefully suggest chrome and firefox as alternative default browsers, which would solve about a million security and maintenance issues.
And as far as desktops goes, I can't imagine home PCs with windows XP is a gigantic money making demo for the average project of your average developer here.
3
Apr 19 '13 edited Apr 19 '13
As much as I agree with you and as much as I can't wait to put the bullet in IE8, it's not that easy.
A lot of consumers don't know jack shit about browsers. To them Internet Explorer is the internet. They are used to it. They like it. The concept of updating to them is pointless. It'll take a lot of time (in their minds) and theres no noticeable difference (again, in their minds.) I recently migrated my grandad over to Chrome. He keeps asking me how to do everything because it's different and he says 'I dont see the point, the websites are the same!'
Some businesses require IE6. The have massive policies in place that'll take years to shift. An employee can't just 'download chrome.' Their computers are locked down to that one browser and asking for anything else requires a huge overhaul.
1
u/zzzwwwdev Apr 19 '13
Thankfully on your second point many of these companies have begun / are beginning to make this transition; especially organizations who take security seriously (since IE6/xp tends to be very vulnerable compared to newer software).
Both of your points are valid though. Know your audience, and make sure you support them.
1
u/WoollyMittens Apr 19 '13
Financial institutions are only barely crawling out of the Windows 2000 era though and they're the ones with all the money. :(
1
1
u/danvasquez29 Apr 19 '13
I would personally expect that anyone who still uses a windows 2000 box at their desk would have such a hard time browsing on it that they just wouldnt and use their phone instead.
Other than that all I can say is that if that's your core demographic, i agree and you're kinda stuck. And you have my condolences.
2
u/zzzwwwdev Apr 19 '13
Comparing (gzip/minified) filesize of Recent Versions of jQuery
Version Filesize (bytes) 1.5.2 29,921 1.6.4 32,075 1.7.2 33,647 1.8.3 33,456 1.9.0 32,962 2.0.0 29,022
0
Apr 18 '13
[deleted]
3
u/Fabien4 Apr 18 '13
I disagree.
Python 2 and 3 are two languages that will probably exist concurrently forever.
JQuery 2 is the official version. JQuery 1.9 is the legacy version, for IE 6-8. They made a special version for older IE versions, just like we do whenever we make a website/webapp. There's a reasonable expectation that IE 6-8 will disappear in a few years, and so will jQuery 1.9.
2
u/krues8dr Apr 19 '13
Except not all of the plugins have been ported, and jQuery 2 isn't always backwards compatible. And who knows how long we're still going to be supporting IE8. So yeah, I think the Python reference is spot on.
3
u/reflectiveSingleton Apr 19 '13 edited Apr 19 '13
Not 1.9 compatible? I have seen it noted that 2.0 specifically supports everything 1.9 does verbatim to somewhat bridge the upgrade path.
Admittedly I have not really tried this out though....do you know of specific issues?
Taken from http://blog.jquery.com/2013/04/18/jquery-2-0-released/
jQuery 1.9 API equivalence: jQuery 2.0 is API-compatible with 1.9, which means that all of the changes documented in the jQuery 1.9 Upgrade Guide have been applied to jQuery 2.0 as well. If you haven’t yet upgraded to jQuery 1.9, you may want to try that first. Be sure to use the jQuery Migrate plugin.
0
u/Fabien4 Apr 19 '13
In that case, jQuery didn't "just Python'd itself", since 1.9 has been out for a little while.
1
1
4
u/rnvk Apr 18 '13
Finally: "As promised, this version leaves behind the older Internet Explorer 6, 7, and 8 browsers"