r/webdev • • Apr 18 '13

jQuery 2.0 Released

http://blog.jquery.com/2013/04/18/jquery-2-0-released/
105 Upvotes

48 comments sorted by

4

u/rnvk Apr 18 '13

Finally: "As promised, this version leaves behind the older Internet Explorer 6, 7, and 8 browsers"

-1

u/[deleted] Apr 18 '13

As well as not being backwards-compatible so 95% of the plugins now do not work.

Still using 1.8.3.

11

u/pheliam Apr 18 '13

But don’t worry, the jQuery team still supports the 1.x branch which does run on IE 6/7/8. You can (and should) continue to use jQuery 1.9 (and the upcoming 1.10) on web sites that need to accommodate older browsers.

5

u/destraht Apr 18 '13

I'm still using 1.8.3 as well because 1.9 removes $.browser. I think that removing this in the 1.* series was a mistake because it is often used to detect IE 6-8. Since 1.9 still supports this it should have been left in. Then version 2 would not have needed this.

3

u/zzzwwwdev Apr 19 '13

According to this page, $.Browser was deprecated in 1.3. Its generally considered bad practice to detect browsers anyway. Detect the feature. If you want to use the newest tools, use current best practice. If not, old jQuery versions still work fine. I applaud their decision.

1

u/Phreakhead Apr 19 '13

Sure it's considered bad practice, but I've worked on tons of sites that require some weird fix for some very specific browser version (e.g. video tags in Android bugging out when there's more than one source, etc.).

Removing support for browser detection is very idealistic, in an industry where pragmatism is king and idealism is useless.

1

u/zzzwwwdev Apr 19 '13

where pragmatism is king and idealism is useless

then why are you writing your own code for HTML5 video? And if you're doing this kind of thing frequently, why not use modernizr, which is a nice clean way to detect features not the browser which is almost always better.

But yea, I agree with you on that quote. I personally can get away without such hackyness and I think it results in more maintainable code. Maybe its because many of my projects are relatively simple. Need a video? I use a YouTube embed. If I want new HTML5/CSS3 features I make sure they gracefully degrade or I do it the old way if its easy enough. I do have to resort to conditional comments, or hacks maybe in 1 of 10 projects but I've found pretty easy to avoid once you know what you're doing.

1

u/Phreakhead Apr 20 '13

I guarantee you that YouTube is using every hack in the book. You may not be testing on enough devices if you aren't! Or your stuff is simple enough that you don't have to deal with complex support across hundreds of devices. The bugs are there, only in certain browser/builds/OS combinations, and Modernizr is definitely not going to help you with that. Of course use feature detection first, but if you need to work around browser bugs you'll need resort to browser sniffing.

1

u/zzzwwwdev Apr 22 '13

YouTube uses the hacks so I don't have to. That's the point.

Maybe we are just talking about different types of project. Could you perhaps give me a few more examples of "browser bugs" you struggle with? I'm honestly curious - I don't want to get myself under any incorrect presumption that I'm so good at this I don't need hacks lol.

As for my testing; Usually I do Latest Chrome, FFox, Safari, IE7/8/9/10 (compat mode, not VMs) on Mac/PC, 1 android (my HTC Rezound), 1 iphone(usually 4), and an Ipad when I can borrow one - though sometimes I get lazy when I'm doing something I've done many times before. Sometimes I use browsershots.com. Obviously this isn't exhaustive by any means, but seems to cover the most common set-ups. I probably should have some VMs set up, etc.., but that sounds like a lot of work ;-)

5

u/Klathmon Apr 19 '13

got any proof to back that claim up? 95% seems really freakin high to me...

4

u/Serei Apr 19 '13

Have you tried jQuery Migrate?

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.

1

u/[deleted] Apr 20 '13

Now plugin devs have v2.0 to test their plugins against, whereas before they didn't.

Patience, Daniel-san.

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

u/Fabien4 Apr 19 '13

Yeah, jQuery 2.0 is for people who are already using jQuery 1.9.

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

u/[deleted] 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

u/[deleted] 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

u/[deleted] 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

u/tw2113 Apr 18 '13

I support this move

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

u/[deleted] 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

u/[deleted] 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.

  1. 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!'

  2. 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

u/Fabien4 Apr 19 '13

I wonder if there are people out there planning to upgrade to IE6.

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

VersionFilesize (bytes)
1.5.229,921
1.6.432,075
1.7.233,647
1.8.333,456
1.9.032,962
2.0.029,022

source: http://mathiasbynens.be/demo/jquery-size

0

u/[deleted] 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

u/krues8dr Apr 19 '13

Python 2.7 has been out for a little while.

1

u/[deleted] Apr 20 '13

jQuery 1.9

console.log("something")

jQuery 2.0

console.log "something"