I’ll never say that you can’t hate jQuery, but you do need to have a legitimate reason you can articulate, because the case to give the library the reverence it deserves is pretty solid, and the case that we should quickly run from it because “😠😠😠JQUERY😠😠😠” is weak and based on some concerns that I think are largely exaggerated.
jQuery helped make the web — and you — what they are today.
On top of that, there’s a good chance it also left a mark on who you are as a developer. Especially if you consider yourself to be self-taught, the authors of jQuery helped make entry into and competency within this field a little more seamless. In fact, if it weren’t for the smoother learning curve jQuery provided, some developers might have thrown in the towel altogether.
Of course, I’m mainly speaking from personal experience. When I started myself, working with
$('.class').slideUp() was far less intimidating than trying to first write a CSS class with an easing transition, and then apply that class with
document.querySelector('.class').classList.add('my-class'). I was able to do the work required of me with less training and time, and it gave me a level of satisfaction through my productivity that kept me interested in sticking with the discipline. Thanks to the easy-to-grasp-and-get-crap-done API the library provided, jQuery (and other libraries like it) undeniably played a role in how effectively I became immersed in the field.
It’s probably not hurting anybody.
While a lot of the dismissal of jQuery often just sounds like “because jQuery,” one of the more common concrete objections is the performance implications of using or sticking with the library. And it usually comes in two parts.
That ‘good enough’ level drops even further when you consider how willing we are to throw in other modern packages of similar file size without much thought. Often, the same people who want to violently kill jQuery are the same ones who are completely fine loading React or Vue onto a page for a relatively small feature. Just take a glance at the weight of React specifically, which is, at best, approximately the same in foot print size, and at worst, even heavier than jQuery, minified and gzipped.
React 16.2.0 + React DOM = ~32KB jQuery 3.3.1 = ~30KB
But despite these numbers, for some reason, because React is React, “bloat” is much further down on the list of concerns, regardless of the context of its use.
Fine. What about the people who are concerned less about file size and take more serious issue with the performance of the library itself?
Related to that, the circumstances in which jQuery is often used just doesn’t warrant this type of performance. I’m not saying it’s unimportant — just that it’s not worth upending your workflow just to gain a few more performance points. The ROI of rushing to strip out jQuery on this basis alone is tremendously low, making it another insufficient excuse to hate it. Sometimes, it’s just a marketing site, and no one’s going to leave your site enraged that your pop-up modal didn’t perform a few milliseconds faster.
But! You probably shouldn’t use jQuery for a new project.
If you’re starting a new project, I don’t think jQuery should be on the list of resources to leverage.
But if you’re working with a codebase that incorporates jQuery, it really is OK to keep using it. You’re not a bad person, and you’re not a crappy developer. In fact, if you’re probably one of the smarter ones, because you’re not frantically running from a library that still does a darn good job at what it was designed to do.
So, don’t fret. When the time is right, dispose of jQuery. But when you do, do it out of smart decision making — when the time is right, when the ROI is significant, and when your project calls for it. Nothing else.