You might not need jQuery

Published On July 12, 2016
- Posted in Blog, Opinion, Projects & Know-How

In the good ol’ days of the www, JavaScript used to be a mess (it’s not so bad nowadays), but there wasn’t too much of an alternative.  John Resig was aware of this and came up with the awesomeness known today as jQuery, which changed the web for the better.  It provided cross-browser consistency and an elegant API.  With this, jQuery became widely used and probably the most well-known JavaScript library to date.

jQuery solved the hard problem of the then-primitive JavaScript, and people liked jQuery so much that a lot of them didn’t even bother to learn “vanilla” JavaScript anymore.  There was not enough reason to do so, jQuery was always around.

In recent years however, JavaScript really got its shit together: it introduced support for CSS selectors via the “querySelector” method; it introduced consistent event listeners, awesome support for Ajax calls (in the olden days, people had to sacrifice their eldest in order to write Ajax requests in vanilla JavaScript, but even then it would not work that well), and the list can go on.  And with the addition of HTML5 API, JavaScript is in a better shape than ever!

Believe it or not, kids, but the golden age of JavaScript has just started. You can have JavaScript on the backend, you can manage dependencies with JavaScript, you can automate processes with JavaScript, you can build highly performant applications with JavaScript, and there are a lot of tools and libraries that leverage the potential of JavaScript (probably you’ve heard of React or Webpack, you should really try them if you haven’t already).

It feels like every month a billion new WhateverJS frameworks and libraries are being released, updated or announced, and all of them have the potential to be game changers. This leaves you, my dear reader, worried that your knowledge might get irrelevant in a couple of weeks and confused for not knowing what to focus on next.  But fear not, child, and check out this talk by Todd Motto to find some peace of mind.

Javascript_bad_parts

Where does this leave jQuery, then, you might ask?  For what it’s worth, I think jQuery has served its purpose, but for most purposes, its time has passed; it is objectively slower than native ES5 and ES6, and it’s also an extra file of 100kb you need to load.

I would still go for jQuery if I have to support IE8 or lower, but for IE9+ I would go full-on ES5.  And then even IE9 and IE10 are becoming obsolete.  Some might say they were obsolete from day one, but that’s mean, and picking on IE is overdone and is too easy (it also shows a lack of sportsmanship and a disregard for the hundreds of millions of users that had used them).

jQuery can still be useful as a dependency for some libraries you might need, and it’s better than to waste weeks reinventing the wheel (sometimes it’s healthy to try, though, as it may prove to be a good lesson – if you and your calendar are up for it).

To learn more, check out these really awesome docs on MDN, and as a piece of homework, check this out.

To recap: later versions of JavaScript (ES5, ES6) will provide the functionality for most of jQuery’s use cases, so if you make your living by changing classes on elements, making Ajax calls, or messing around with event listeners (and all these on browsers not older than IE9), you might not need jQuery.

 

by Nicu Cornea

Related Posts

Comments