HACKER Q&A
📣 brettermeier

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.


  👤 lofaszvanitt Accepted Answer ✓
As a web developer you seemingly trust user input... ABOUT others' preferences... nowadays? :DD Either you know what works for you and use that or jump on hype trains and going to fell to your death sooner or later.

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...


👤 acdha
There are a fair number of answers about it being old, and I think that it's really important to contemplate what age means for software: the most obvious answer is that you can now use newer standard APIs for a lot of what jQuery did (which, to be clear, is great!) but also that there's been a lot of time to build a ton of projects using jQuery and for those projects to follow the common trajectory of starting simple and growing more complex over time.

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.


👤 romanhn
I imagine its wide use is residual, due to how prevalent jQuery was in the past. It is hard to describe how much of a godsend it was back when client-side coding meant dealing with quirks of major browsers and their different versions. It became absolutely dominant in an era right before the explosion of JavaScript libraries that we're still dealing with. Calling it a "big failure of the past" is nonsensical - it solved a very real problem in a very elegant way, and it was a must have for any modern (then) developer. It's no longer nearly as relevant because the browsers by and large addressed the underlying problem, but it does not surprise me that it is still entrenched in many a codebase.

👤 tobinfekkes
Because unfortunately, tech people equate old with bad.

Meanwhile, 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.


👤 furyofantares
You can probably just ignore any claim that jQuery is a big failure from the past - it's a massive success from the past. The huge problems it was solving so well just aren't problems anymore. You can certainly still use it.

👤 olliej
JQuery wasn’t a big failure of the past, it was a hugely important library that helped make robust interactive sites in the browser landscape of the time. That landscape has changed so it has become less relevant, and coupled with modern webdevs having decided that it’s reasonable to just say “use chrome” just as they said “use IE” before it, means that such a library is no longer as necessary.

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.


👤 themodelplumber
The tech mindset is generally focused on change moving forward. Over time, jQuery was seen as a blocker for a number of areas:

- 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...


👤 elviejo
For the same reason why we still use PHP. Because it keeps it's promises. So it does want it says it is going to do reliability.

👤 idontwantthis
JQuery is great for DOM interaction. If you are making a complex web app, you should be using a framework designed for that and DOM interaction not through the framework is going to cause problems and convoluted code with side effects.

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.


👤 sandreas
jQuery once was designed to overcome JavaScript API differences in browsers and provide cross browser DOM manipluation and event handling, while still being as user friendly as possible - and it worked very good. You did not have to care - just use jQuery and you were done with cross browser stuff.

But it came at a cost. jQuery basically is a function that is linked to '$':

  function jQuery() {
     // ...
  }
  
  $ = jQuery;
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:

  $ = document.querySelectorAll;
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...


👤 connordoner
I think a lot of it is technical debt — it really was the bees knees ten years ago!

👤 tmnvix
Many useful UI components were written using jQuery. I no longer write anything in jQuery but I still use it at times because of this.

Give it another 5-10 years and I might find myself saying the same about React.


👤 chiefalchemist
A fair amount of hate for jQuery is due to how it's used (read: misused) and not the tool itself.

For example, dev adds jQuery to a project when 5 to 10 lines of vanilla JS would do.


👤 yen223
A lot of what jQuery used to provide is now baked into browsers, so for the most part jQuery is redundant nowadays. You'd still see it show up probably because the cost of removing jQuery from older systems usually isn't worth the hassle.

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.


👤 flamesofphx
I don't mind it for things when really needed, if I just want a few of it's conveniences for a modern website, I will use one of the tiny replacements for it like "cash.js"... I am with a lot of the other, if they would make a "Real" slim version that cuts out all the really old browser support, I would be using it again...

👤 jschrf
Imperative, DOM bound. Try writing a library of reusable components or a large-scale app in jq. Or dont.

UI should be declarative and cross-platform.


👤 nuc1e0n
It's probably due to legacy software. If your software that uses jQuery ain't broke, why risk breaking it by striping it out? Does doing so even provide much business benefit? Probably not I'd say.

👤 lbotos
jQuery was written to give you a nice interface when browsers were less standard. Read here for examples of what it was working around:

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/


👤 soueuls
It was very useful in the past, but most of the problems it solved does not exist anymore.

I used it extensively because I never really like the imperative approach, it’s a bit too error prone


👤 guinness74
jQuery is still shipped with WordPress and Drupal, two of the most popular CMSes out there. So I'm sure that accounts for some of it.

👤 ilovhn
It's hated because it's frequently used.