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.
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";
}
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.
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.
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.
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.
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
fetchbecomes universal, there's not really anything left.