Ask HN: Why is jQuery hated but frequently used?
When you read HN or other programmer focused sites, you will read continuisly about that jQuery is a big failure of the past and should not be used anymore.
But when I look at current statistics (https://trends.builtwith.com/javascript/jQuery) or Enterprise software like SAP's Fiori UI5 framework, there is very often jQuery implemented.
Why is that so? I mean, if all those people are right, who are complaining about jQuery, why those big players still use it? Is it really because of old habits and technical dept, or is it because it is good?
I must say, I really enjoy writing JS with jQuery, still today. It's short, understandable, simple... Maybe not the fastest, but I really don't know if that's really the case.
37 comments
[ 3.8 ms ] story [ 65.4 ms ] threadMeanwhile, old can also mean the bugs have been worked out, doesn't change too drastically, and it's relatively stable.
jQuery gets the job done and has a low barrier of entry.
Worry less about what people think about a tool, and use the best tool for the job (even if you get flack for it). You'll win in the long run. When they're having to refactor their codebase, you're skirting by the wayside with reduced maintenance time and costs.
- Browsers and the web becoming less painful to work with out of the box. If we all keep using jQuery, will these issues it fixes ever be addressed?
- Dependencies that hang around for a long time tend to increase technical debt or fear of common dependency-related issues
- A huge part of membership in a community involves signaling. Some of that signalling means syncing with what isn't liked, and speaking against it.
So you can get some people who want to live in a better world, some who want to be less annoyed by clutter they don't need, and others who just want to belong...and they see jQuery as a cheap ticket, especially if they aren't using it.
Still, jQuery is like any tool, best used by those who have a plan for working around the troublesome aspects...
That's true, but the beauty of jQuery code is still missing in current JavaScript. It would be nice in my opinion if JavaScript would copy something of that shortness and beauty, that jQuery brings with it.
It would be interesting how much jQuery is needed to maintain compatibility over different browsers today, in the past that was the main use case. But nowadays I would use it because the code is a beauty to read and to write. For that beauty you need to load 87,5 KB of additional data, but that's not very much.
Still I get the idea of not needing to use another library. But I never saw that a new version of jQuery broke any code, but that may be my mistake.
It’s been ages since I last had to look up an element by ID or toggle classes. That stuff just doesn’t exist in the new way of doing things.
jQuery does one thing very well: abstracting away the peculiarities and idiocies of Ecmascript plus the browser quirks and provides a much easier way to do everyday things. The JS/ES implementations today are much better, than back in the IE days, but jQuery still provides an easier way to do things. JS standards bodies should have gone to John Resig with a big briefcase, give him a blowjob and asked him to let use jQ as it is and make it a standard. NOOOO, they had to implement everything in a convoluted way.
Plus a lot of devs know it from the heyday of the web, so why dump it, because "Stackoverflow statistics" say it's not trendy anymore? Gimme a break.
Speed issues in a JS app written in JQ in 2022? Gimme another break.
Now, you have these modern JS framework abominations... and people believe these are the second coming of God. :DDD Literal idiots everywhere. Everyone copies some bigdick thought leader/bigname company and think they evolved, when they actually do the same, just in a much more complex way.
Well, somehow you have to employ more people and slow down big corporate growth...
I’m not mad about it. I’m just always surprised to see it. My maturity level hasn’t reached production yet. I’m sorry.
I prefer using jQuery over the DOM interface because it's well ahead of the browsers, and you completely avoid bugs where you might implement something that's supported in Chrome but will be supported in the next version of Firefox, but you're running Firefox Nightly locally so it appears to work for you. But jQuery's big mistake, IMO was insisting on retaining support for older browsers.
If jQuery had created a jQuery.next or something like that, which dropped support for non modern browsers and focused on ensuring a common interface to the latest browsers and monkey-patching missing features into browsers which don't have them yet, I think it would continue to be popular with a significant developer base.
For example, dev adds jQuery to a project when 5 to 10 lines of vanilla JS would do.
But I get it, if that page would be loaded by thousands of people each day, you may not want to make them all to load an extra jQuery file for what you could have written instead as a Script tag in a HTML file.
I’ve seen a few people over the last few years saying that whatever framework is currently popular should be built into the browser, and in its era people were saying the same thing about jquery - and vigorously arguing for it.
I would question the notion that jQuery was considered a failure back in the day. jQuery was practically necessary if you didn't want to deal with cross-browser issues.
Programmers tend to love building new things more than maintaining code and we're _really_ prone to misattributing the causes of problems, especially when that would mean admitting that we're not as good at managing complexity as we hoped. When Facebook's marketing push really got rolling, it started a fad of people crapping on jQuery and talking about how amazing React was — and I saw almost none of them built something which was either faster or, within 6 months, much easier to work on. The only exception I remember was a time where the React rewrite was what gave them political cover to slow feature development enough that they could fix a known design flaw.
That's not to say that newer tools are bad but the teams who did see benefits were already relatively mature: they actually measured performance, had a stable testing approach, refactored regularly rather than letting technical debt pile up until is burst into flame, etc. They would have been successful with almost any tool, and tended not to trash-talk jQuery when they left it behind since part of experience is understanding how much your choices matter.
UI should be declarative and cross-platform.
Give it another 5-10 years and I might find myself saying the same about React.
https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0Rlh...
It still works, but you "might not need it" if you were using it for "workarounds"
https://youmightnotneedjquery.com/
If you are making a web-site and not a web-application, it's great.
A lot of pain comes from a project that evolved from a complexity where JQuery was a good choice to a complexity where it is not a good choice, and the work wasn't done to convert the existing stuff.
But it came at a cost. jQuery basically is a function that is linked to '$':
The problem with jQuery today is, that most of the time the cross browser stuff is no longer necessary and therefore slows down your app drastically (especially hooking in every event handler). Most jQuery 'advanced' features are not used very often. This basically means, that in simple apps you could nearly replace jQuery with: jQuery is also often very inconsistent. Take for example the function itself - you can use different types of arguments (jQuery(function(){}), jQuery('string'), jQuery([]), etc.). In a small app, this does not make a difference, but nowadays, with HUGE JavaScript applications, this can be a real problem.Most users liked the easy API of jQuery and don't know about these facts, so jQuery often is still the way they go...
I used it extensively because I never really like the imperative approach, it’s a bit too error prone