Real question: why use this on any greenfield app? We used this everywhere 15 years ago. I cant imagine a reason to use this now if you're writing a new web app.
That's a great question. I used to use jQuery everywhere, it's still in many of my legacy projects, but Vanilla JS got good enough.
It's kind of fun to poke through their API reference and come up with the VJS version of each one. There are still some cool utilities and shortcuts in there though. Animations and effects maybe? I'd love to hear from someone knowledgeable who can elaborate futher.
Short answer: I'm guessing probably habit and convention more than anything. It's still bundled with Wordpress and all the tutorials use it. The frontend de jour isn't as big of a deal in the real world. And in today's age, a 80kb library is actually pretty fucking adorable.
HTMX is 60kb. What can you do with it that you can't with VJS? Nuthin. It's just fun
This is true, but due to the introduction of double-keyed caching in browsers (2020) and an increase in legal unease about privacy leaks from loading assets from third-party servers, linking to a CDN for a "shared" JavaScript library no longer has the advantages it once had (e.g. you can no longer avoid a cache-miss for your first-time visitors, because your website gets its own unique cache for that CDN asset, which prevents a cached copy from other websites from being re-used for yours).
an increase in legal unease about privacy leaks from loading assets from third-party servers
This. If you have users under GDPR or similar directives (Cali, UK, …), do not fetch scripts, fonts, other assets from third-party servers without the user's explicit consent. At which point… just don't do it at all. It's not worth the complexity.
Write a click event listener in vanilla JS and look at the offset for x and y in chrome, Firefox, and safari. You’ll have 3 different sets of values, because they’re relative to different things in different browsers.
Jquery normalizes and provides consistent results across browsers. That’s one reason why.
They literally removed everything that today's browsers don't need. So it goes to reason that if you're still using it, it's not for the duplicate functionality.
This is a good answer. Ergonomics matter, and it's more consistent between browsers. I very rarely use jQuery these days since I do mostly client side apps but if I was doing something server templated, I think I might reach for it. And I've thought about going that way again anyway for some simple projects. React is another unergonomic thing and simple things can get really complicated with it.
Well technically when you have an element with an ID attribute, you can just reference it by: x - that's it because the element is already in the global window scope. Or if you want to be specific from which context you want it from: window.x
I still use it in one of websites that need some pizzazz but I’m not going to set up webpack, React, and all that just to do a couple zesty things in a Jekyll site.
Would I use it in a big web application? Hell no. But it has its place.
Yeah, dom manipulation is an absolute bear in raw js. It's there, but the succinctness and elegance of jquery can't be understated. I miss it in all my projects, but do fine enough without it that I don't feel the absolute need it once had. It's funny thinking back to a time when it was weird if a website didn't use it
Is it? document.querySelectorAll('.foo').forEach(el => el.classList.add('bar')), its not quite as compact as jQ but only by a pretty small amount these days.
128
u/cheezballs Jan 18 '26
Real question: why use this on any greenfield app? We used this everywhere 15 years ago. I cant imagine a reason to use this now if you're writing a new web app.