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

View all comments

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