r/programming • • Jun 09 '16

jQuery 3.0 Released!

https://blog.jquery.com/2016/06/09/jquery-3-0-final-released/
1.1k Upvotes

354 comments sorted by

View all comments

43

u/earthboundkid Jun 09 '16

Most of what I used jQuery for was working around browser incompatibility. As IE11 becomes the trailing edge browser we need to support, the need for jQuery shrinks to zero. Once fetch becomes universal, there's not really anything left.

128

u/EternalNY1 Jun 10 '16 edited Jun 10 '16

As IE11 becomes the trailing edge browser we need to support, the need for jQuery shrinks to zero.

Not true, because they can slim down jQuery (as you see with 3.0) which still allows you to turn what might be 20 lines of ECMA-compliant JavaScript into a one-liner that even assures you much better compatibility.

It's still useful, as long as it's not bloated, and fast.

It makes your own code more readable ... the whole "DRY principle".

This?

var d = document.getElementsByClassName("goodbye");
var i; 
for (i = 0; i < d.length; i++) { 
  d[i].className = d[i].className + " selected";
}

Or?

$(".goodbye").addClass("selected");

52

u/stns_da_mnns Jun 10 '16

Someone who gets it! There are far worse things to do than include jQuery to make your webpage slower. Who needs 4K images on a focking phone?

61

u/EternalNY1 Jun 10 '16 edited Jun 10 '16

Yes. I try to explain it, people don't get it.

And by "people" I mean "developers" which makes it even more frightening.

Sadly, as a senior developer I've had to lay people off after I asked them, politely, numerous times to please stop trying to squeeze out the extra 15 milliseconds of some function that runs once a day and focus on the real problems on the list.

And not "Lumberg" politely ... just trying to explain that it is not a priority and we have bigger problems. It sucked. But soooo many people do this.

Because if you can shave it from 30 ms to 15 ms ... that's twice as fast. To the one person who might run it, once a day.

"But you have to pull in the whole library!".

Yes, well your logo in the top left corner is twice the size of jQuery and could be 100 times smaller and look the same.

Oh, and jQuery wasn't actually downloaded as you can see in the developer tools network panel ... it's cached on almost everyone's machine.

25

u/[deleted] Jun 10 '16

The three things you don't bring up at the dinner table: religion, politics, and jQuery.

6

u/vplatt Jun 10 '16

Wait... you said religion twice!

→ More replies (8)

12

u/puhnitor Jun 10 '16 edited Jun 10 '16
[...document.querySelectorAll('.goodbye')].forEach(goodbye => goodbye.classList.add('selected'));
→ More replies (48)
→ More replies (50)

33

u/HokumGuru Jun 10 '16

TIL fetch omg

66

u/kupiakos Jun 10 '16

Stop trying to make fetch happen! It's not going to happen!

→ More replies (2)

9

u/[deleted] Jun 10 '16

You can use fetch today https://github.com/github/fetch

9

u/kovensky Jun 10 '16

The main problem with fetch is that it's not cancelable -- but on the majority of use cases you don't need cancellation anyway :D

→ More replies (3)

4

u/sparr Jun 10 '16

As IE11 becomes the trailing edge browser we need to support

Please tell me this is a real thing, somewhere in the world.

I left a job late last year where we were discussing dropping support for IE6. This was at an entertainment website company.

10

u/gearvOsh Jun 10 '16

Uh what? Every company I've worked for dropped IE6 over 4 years ago. IE8 was dropped about 1-2 years ago. IE9 is next.

Whatever company you are working for has no idea what they are doing, except for the instance where their actual traffic comes from those browsers.

4

u/earthboundkid Jun 10 '16

Yeah, IE6 is really just an unpleasant memory at this point. We stopped at IE7 in 2013, 8 in 2014, and jumped to 11 at the end of last year.

2

u/sparr Jun 10 '16

1-2% of their traffic comes from <IE8

5

u/gearvOsh Jun 10 '16

No where near warrants support.

2

u/MattBD Jun 10 '16

Microsoft don't support anything below IE9 nowadays. If the creator of a browser doesn't support it anymore, there is absolutely no justification whatsoever for anyone else doing so.

2

u/[deleted] Jun 10 '16

The software industry is filled with executives that view "money on the table" as a weakness of their sales process.

Justification isn't necessary, only rationalization.

→ More replies (1)
→ More replies (2)

6

u/kevrom Jun 10 '16

Fetch is a simple polyfill (or 2) away. So ajax is not a valid excuse to include jQuery. Complex animations with jQuery are probably much easier than most counterparts, but that's about all I can think of really.

9

u/omnius19 Jun 10 '16

Check out gsap for complex animations. If you are coming from jQuery animations, it will blow your mind.

3

u/The_frozen_one Jun 10 '16

What do you think about Velocity.js?

3

u/omnius19 Jun 10 '16 edited Jun 10 '16

Velocity.js is a great project as well. It is essentially a complete replacement for jQuery's $.animate, although it does not need jQuery to operate anymore. It performs orders of magnitude better than jQuery, or at least it did before jQuery switched from using setTimeout to requestAnimationFrame for timing in this latest release. Also Velocity is MIT licensed. Gsap has a very permissive (free for pretty much all uses) but closed license that some will not like.

However, in my admittedly limited experience with Velocity, it falls short of Gsap when it comes to creating complex animations. The main issue is timing. Gsap has timeline functionality which lets you schedule multiple animations in sequence. It handles conflicts between animations changing the same properties at the same time. With Velocity, it is harder (at least in my opinion) to handle multi-part animations and to replay/pause animations in a reusable way. Also, I have had problems with Velocity handling transforms in weird ways compared to Gsap, although this was a while ago.

I see Velocity and Gsap as having very different purposes. If you want to make truly complex animations (think drag and drop interfaces, complex svg animations, form validation with many interacting elements, etc), Gsap is probably what you want. It is more robust and reliable. However if you just want to do simple things like sliding up a div or if you want to replace $.animate with a significantly more performant solution without changing any code, Velocity is perfect. It is much lighter weight than Gsap (although gsap is separated out into modules so you can include only what functionality you need for a project) so for simple use cases, Velocity may be the better choice.

Here is more from the creator of Gsap. Note that Velocity is no longer just a jQuery plugin.

2

u/destraht Jun 10 '16

As far as I know Fetch doesn't support timeout callbacks and stuff like that.

→ More replies (11)