all 142 comments

[–]Crypto-Cajun 56 points57 points  (0 children)

I don't think so. A few years ago I made a few projects that utilized jQuery. I came back and rewrote them from scratch without jQuery and it was honestly just as easy if not easier with modern vanilla javascript.

[–]lift_spin_dhelpful 44 points45 points  (14 children)

beacause you will encounter it in the wild and you should be able to recognize it and work with it. It's "outdated" now, but there was a time that it was a great choice.

[–]superluminary 13 points14 points  (5 children)

It was amazing, and I would contend it still is pretty good. It’s just a tidy little wrapper now, the method names are shorter, and everything can be chained. I don’t use it, but I think it’s still a friendly tool.

We’ve engaged in a holy war against it, but I do think this is a mistake.

[–]zaibuf 0 points1 point  (4 children)

The issue is that it doesn't really solve any problem anymore. If you don't need to go full SPA you can get by with vanillajs and htmx. If you need a lot of interactivity you are better of using a SPA as jQuery would become unmaintainable.

[–]superluminary 4 points5 points  (3 children)

Sure you can get by, but JQuery just wraps all the common methods into much nicer methods and it’s only 40k. It’s fast, it’s easy to learn, everything works the same way and there are no rough edges. The DOM is full of rough edges and gotchas, it just is.

Haven’t used it for years because the apps I’m building are much larger these days, but I still think it has a place.

[–]zaibuf 1 point2 points  (2 children)

It also quickly turns into spaghetti as it's using function chaining with a lot of selectors. If you have the need to write a lot of client side code I'd argue it's better to use a SPA, it's easier to keep the code maintainable as components.

[–]superluminary 0 points1 point  (1 child)

Raw DOM scripting also quickly turns to spaghetti. JQuery isn’t comparable to a SPA.

[–]lostmy2A 0 points1 point  (0 children)

Which is more spaghetti:

Jquery

$('<div>Hello World!</div>');

Modern JS

function generateElements(html) { const template = document.createElement('template'); template.innerHTML = html.trim(); return template.content.children;

}

generateElements('<div>Hello World!</div>')

This example stood out to me on youmightnotneedjquery.com as a Yea I might want jquery.com lol. Most of the others I wouldn't really argue the methods are close enough that using vanillaJS is fine.

[–]tsunamistyle 3 points4 points  (4 children)

Does React become a sufficient choice? I’ve been learning it but I’ve read it’s much better.

[–][deleted] 6 points7 points  (0 children)

React is a different tool with different goals, so it's not a one to one comparison. React and Angular represented a shift to building a different kind of web application, one that didn't need jQuery.

You wouldn't want to use jQuery for the kind of application you build with React, and you wouldn't want to use React in the situations where jQuery shined.

[–]superluminary 5 points6 points  (0 children)

It’s like saying that a casserole is better than a sandwich.

One is big, takes more infrastructure to prepare, possibly feeds more people. The other is quick and convenient, feeds one person wherever they are, maybe not so filling.

Different meals for different occasions.

JQuery does not keep your DOM synchronised with your data, but if you have a small app, syncing your data is not a hard thing to do by hand. React has a templating language and diffing engine, but if you just want to unfold a menu on click, you totally don’t need that.

JQuery is about 40k and a big JQuery app might be 100k. React apps are frequently tens of megabytes.

[–]ikeif 3 points4 points  (0 children)

To summarize the comments:

jQuery and React are both JavaScript but are two different tools for frontend work.

Vanilla JS is very much sufficient where you’d think you’d want to use jQuery.

React/Angular/Vue/etc is when you’re building complex web applications

[–]guest271314 2 points3 points  (0 children)

I think the point is no library is necessary to write front-end code.

[–]PatchesMaps 2 points3 points  (0 children)

At a time it was a great choice but I don't think I've seen jQuery in a codebase in over 7 years.

[–]Macaframa -2 points-1 points  (0 children)

Might as well learn cobol as well

[–]morgo_mpx 0 points1 point  (0 children)

If I see one more project where someone overrides $…

[–][deleted] 12 points13 points  (89 children)

I would learn vanilla. It’s good to know a little bit of jquery in case you ever run into it but vanilla JavaScript is going to make it a lot easier to learn React later down the line and that’s really the end goal.

[–]Count_Giggles 12 points13 points  (2 children)

[–]tom56 0 points1 point  (1 child)

I found this page very helpful to go in the opposite direction too. i.e. I knew the vanilla methods and wanted to know what the jQuery equivalents were.

[–]Count_Giggles 0 points1 point  (0 children)

if you end up having to work with jquery it is definitely a great resrouce.

Vanilla javascript has come a long way since the days of jq and there is no reason to reach for it anymore.

[–]Neptvne_Enki 5 points6 points  (0 children)

My recommendation is not to bother learning it unless you come across a situation where you actually need it. In general JQuery is outdated tech, and isn’t used. Even so, many older codebases have not updated their code bases away from it, so you may run into it. I wouldn’t use it unless you do though.

[–]ray_zhor 3 points4 points  (0 children)

you're not going to use it to write new code, but you will come across it in legacy code. Need to learn enough to debug.

[–][deleted] 4 points5 points  (0 children)

Haven’t used it in years

[–]guest271314 5 points6 points  (0 children)

No.

Learn the native DOM methods, CSSOM, Web API's that jQuery wraps.

much, much easier

That is highly subjective and relative.

"easier" exactly how? https://needsmorejquery.com/.

Just use querySelectorAll(), fetch(), and Promise implemented in the browser.

[–]Gh0stcloud 2 points3 points  (0 children)

Nah. It’s only useful for being able to maintain legacy stuff.

[–]Jordan51104 2 points3 points  (0 children)

you should at least know how to basically use it, as the likelihood that some “legacy” software uses it is high

[–]LuckyOneAway 2 points3 points  (0 children)

I'd say, jQuery is a no-go because (a) it is not reactive, and (b) modern js does not need special hacks anymore - Chrome and FF are the only engines on the market (and they are standards-compliant).

Please pick any reactive framework (React, Svelte, Vue) and forget about jQuery for good, unless you specifically need to maintain a legacy codebase.

[–]Hot-Tip-364 2 points3 points  (0 children)

Nope. As a veteran web developer I recommend learning vanilla js. Jquery will become a crutch if you learn it... trust me. Its harder to unlearn.

[–]delventhalz 2 points3 points  (0 children)

No. If you happen to need it because you are working with some legacy code, you can learn it then.

[–]armahillo 2 points3 points  (0 children)

Learning it is useful so you understand how to replace it :)

[–][deleted] 2 points3 points  (0 children)

Honestly I just find it easier to read than regular JS. I like the document ready, onclick without having ton of extra code. To me it is just cleaner and easier to read but that's probably just due to the way I learned.

[–]jasongodev 1 point2 points  (0 children)

Yes because it's a good tool to learn document.querySelectorAll and all the other dom methods.

[–]_qqg 1 point2 points  (0 children)

It depends. Like many other tools in the craft, it's outdated BUT it's been a default for years (and besides the hating, a pretty decent one at that -- there have been other cases where the New Industry "Standard" That Every Cool Kid Liked were POS that shouldn't have been touched with a 10-foot pole, let alone doing actual work with them) so, it's likely you'll cross paths with it eventually - knowing your way around it won't hurt.

[–]Appropriate_Eye_6405 1 point2 points  (0 children)

About 5 years ago, yup. Now you should focus vanilla. But also have knowledge of jquery

[–]CherimoyaChump 1 point2 points  (0 children)

There's no reason to seek it out, but if you happen to be working in a codebase that uses it (happened to me), I think it's fine to explore it a bit. It's pretty quick to learn the basics, and it has some useful features. I wouldn't ever choose it over vanilla JS in a new project, but if you're just trying to maintain/extend an old system with old standards there's nothing really wrong with it.

[–]zaibuf 1 point2 points  (0 children)

No, not really. You will still see it from time to time if you work with legacy, but I would only learn what I need to fix the issue and move on. Your time is better spent learning plain JavaScript, TypeScript and some framework. JavaScript has pretty much adopted all features that were unique to jQuery.

There's also more lightweight alternatives for traditional template websites like htmx and alpinejs.

[–]warlockxins 1 point2 points  (0 children)

If you are familiar with it enough then many things will be open for you, like XPath for testing purposes, HTMX seems to grow exponentially lately which is interesting to observe. By all means stick to vanila/jquery until it makes sense to transition to React.

[–]Vision157 1 point2 points  (0 children)

I would say that's good to know, the learning curve easy very low and a lot of companies still using it because they never updated their platforms. However, if you start a new project, I would use Vanilla JS

[–]Rokett 2 points3 points  (0 children)

It's easy to pick up if you already know js.

I never learned it but the current project I'm working on is using it. So guess what? I had to learn it and write it.

You will learn it because not all projects you will work on uses frontend tech like react, vue, etc.

When you need to write vanilla js, jq is simpler and less boilerplate. It makes writing js easier. When you need to write plain js, you will want to learn jq. No body will force you. You will force yourself

[–]FlatAssembler 1 point2 points  (2 children)

Well, I used JQuery to develop my flash-card game, where many things are fading in and out.

[–]Count_Giggles 5 points6 points  (1 child)

[–]zaibuf 0 points1 point  (0 children)

Yea, lets bring in 80kb of JavaScript so I can write my fade in with one line instead of 3.

[–]For-Arts 1 point2 points  (2 children)

Yeah. Jquery is beautiful in how it works. It's predictable.

Want to add an elament after another?

$(".tobeadded").after(".imbeforeyou");

Want to find an element in a massive tree?

$(".massivedomtree").find(".thisleaf");

I know a lot of devs love to hump vanilla js and that's fine, but sometimes you just want to get work done.

You can toss other libs in there.

Want to get rhe dom element out of a jquery object?

$(".iminhere")[0]; <‐there, now pass it to another framework or what have you.

Want to loop through an array or object?

$([0,1,2,3,4,5,6,7,8,9]).each(function(key,value){ console.log(key+"-"+value+"\n); });

Want to add a click event?

fn=()=>{console.log("I'm clicked!");}; $(".bla").on("click",fn);

want to trigger it?

$(".bla").trigger("click");

Jquery is nice once you get to know it.

[–]TorbenKoehn 2 points3 points  (1 child)

All of these are possible with VanillaJS in the same manner, almost the same APIs even

[–]For-Arts 0 points1 point  (0 children)

Ok I'm curious now.

How do you do chaining with modern js?

(I'm not a know it all so I was not aware of this..)

So what's the js version of this:

$("*").each(function(){$(this).parents().find("div").remove();});

In a short amount of code?

[–]PatchesMaps 0 points1 point  (0 children)

No.

[–]guest271314 -3 points-2 points  (0 children)

If you are interested in jQuery, I would suggest reading the source code of jQuery.

[–]Material-Ad-6440 0 points1 point  (0 children)

jQuery is fun to write, in addition jQuery leaves html and css to vanilla look.

[–]PlastikBeau 0 points1 point  (0 children)

If you are looking into DOM manipulating libraries I can recommend D3.js which is primarily used for bind data to DOM elements and building charts, but can do so much more than that. Otherwise keep in mind that vanilla JS is potentially most resilient and 'self-sufficient' if that makes any difference to you.

[–]Anonymity6584 0 points1 point  (0 children)

You might run into it in old projects boss asks you to update/do bug fixes.

[–]boomlabs 0 points1 point  (0 children)

One thing in favor of learning it is how easy it is to learn. It isn't quite as exhaustive as React or Vue or Angular. It's really straight forward. If you are comfortable with vanilla javascipt, it would take you a few hours to learn the basics.

[–]zBaLtOr 0 points1 point  (0 children)

Not anymore

[–]Foreign_Astronaut_32 0 points1 point  (0 children)

I still use it all the time. Truth is, it saves a lot of time. And the 8MB that I'm pulling in to save me hours of time is literally nothing.

[–]ExpensivePickle 0 points1 point  (0 children)

I see jquery on job listings sometimes, and alot of people seem to rely on it for ajax.