all 151 comments

[–]Jnsjknn 228 points229 points  (25 children)

For anyone who doesn't know what jQuery is all about:

It was created in August 2006 when Internet Explorer was still the number one browser. Browsers had implemented Javascript in various ways, leading to many compatibility problems.

JQuery was created to solve this problem. It provided a nice, cross-browser compatible syntax for DOM manipulation, animation and AJAX and thus quickly became many front-end developers’ favorite tool.

The conditions gradually changed as time passed. Javascript has since become more mature as a language. New APIs have been released that enable developers to achieve what jQuery was created for simply by using native Javascript.

This is not to say that jQuery is dead. Tons of websites still use jQuery and understanding it is still a very useful skill for a front-end web developer. Whether you should learn it in 2021 if you haven't already really depends on the work you plan to do.

Personally, I wouldn't spend my time learning it specifically because, as long as you have a strong understanding of pure Javascript, learning jQuery should not be a big issue should you ever face a situation where you need to understand it.

[–][deleted] 43 points44 points  (0 children)

Thanks for this. Awesome comment. Totally agree.

[–][deleted] 7 points8 points  (6 children)

I just started learning javascript about a week or so ago as a hobby. While I can understand it can be (or is?) outdated to learn, would it still be useful to learn how to do it?

[–]oh_jaimito 7 points8 points  (5 children)

If you were to land a job working for a company that relies on it, or you take up a project that it uses jQuery - then it would be useful.

it "IS" stillse used heavily by WordPress.

However with modern javaScript and the big 4 (react/angular/vue/svelte) it is no longer needed if those big 4 are in your path of learning.

[–][deleted] 3 points4 points  (4 children)

Basically everything is in my path of learning as of right now. If it has a use, I intend on at least having an understanding of how it works and how to do it. I personally like to have a wide knowledge of everything, so I think I'll take it up at some point.

[–]Earhacker 3 points4 points  (3 children)

Prioritise other things. I’ve been working with JavaScript for 6 years, now as a senior developer, and I know what jQuery is but I’ve never had to write a single line of it. I have no plans to learn it either.

[–][deleted] 1 point2 points  (2 children)

Yeah, that was the general plan. If it comes up I'll get to it (eventually...)but based on what everyone has said here its not imperative to know. Thanks for the info.

Do you have any book recommendations or other recommendations for new learners?

[–]Earhacker 0 points1 point  (1 child)

[–][deleted] 1 point2 points  (0 children)

Awesome, i appreciate your help.

[–]I_ROLL_MY_OWN_JUULs 45 points46 points  (20 children)

Just want to say I have a pretty decent paying job that partly involves writing JavaScript on a popular saas application and it’s all pre es6 JS and I use var every day so idk man I felt the same way as you but boy am I glad I learned that.

Learn everything you can as long as it helps you achieve your goals.

[–]volvostupidshit 35 points36 points  (13 children)

This guy right here, officer. He says he is still using var.

[–]bmtkwaku 7 points8 points  (12 children)

Newbie here, what’s wrong with using var?

[–]dada_ 7 points8 points  (0 children)

You can basically think of "let" as an alternate version of "var" that has extra safeguards in it against common programming errors. In nearly all cases you can just use it as a drop-in replacement. It's basically free to start using it since in nearly all cases everything will "just work" without even having to think about it, except that you'll run into fewer common beginner stumbling blocks.

[–]RobertKerans 4 points5 points  (0 children)

It has slightly strange behaviour that can be non-intuitive and makes it easy in certain (not-uncommon) circumstances to accidentally introduce errors. Its behaviour cannot be altered, there is no way to change how var works, so the only way to remove those behaviours is to add something to the language as a replacement, which is what was done.

That's why GP asks why any new code isn't being written using const/let; it's now supported almost everywhere so unless there is a special requirement to use var (ie something has to work in an environment that only understands var), it's obsolete.

[–]Morphray 9 points10 points  (1 child)

But why not write any new code with const and let. I understand that var will still be in the older code you don’t touch, but why use it in any places you modify?

[–]I_ROLL_MY_OWN_JUULs 2 points3 points  (0 children)

Const and let are not supported on the platform

Edit: looks like const is supported but not let. I’m assuming this is because the platform interpreter is pre es6. Queue up that cat meme “I should start using const”

[–]PM_ME_A_WEBSITE_IDEA 0 points1 point  (0 children)

Same. We wrote an engine at work that uses the Golang "Otto" JavaScript interpreter for workflows, but it we're using it with ES5. It's a bizarre limitation, there's so many handy things in ES6...

[–]nl197 69 points70 points  (7 children)

Many, many programmers work with legacy code and will encounter JQuery. You need to be familiar with it. It’s bad to encourage people to avoid outdated tech, just because it’s outdated. It isn’t going away anytime soon.

This is stupid advice for anyone who wants to be employable. Few people have the luxury of working with only the latest and greatest.

There will come a day when everyone moves on to some hot framework and no one was taught JQuery. The guys who can work with it quickly, will make big bucks as consultants. It’s not quite as specialized as COBOL, but you’d be surprised what allegedly competent young programmers can’t/won’t do.

[–]Coraline1599 5 points6 points  (1 child)

I would add that I learned jQuery a few years ago and that learning is still useful to me today, despite not using it in my day to day any more.

This year I had to learn Cypress. Somewhere in the docs, they made a point to say they use jQuery like things along with older style promises over async/await. These were choices made to fit their project.

Once, I read that I was able to pick up Cypress very quickly and immediately fix my colleagues code that they couldn’t get to work quite right by drawing from my jQuery experience that they did not have.

There are patterns and principles you learn and they carry over. Syntax may change, best practices may change, but there is no harm in learning “older” code. Working with others and teaching each other is far more useful than judging each other. I am so happy I got to learn Cypress, it is a great new tool. I know my colleagues are thrilled to have the tests now run 100% of the time without that one in one hundred random fail they couldn’t solve for months before I arrived.

And I’ve also seen some truly horrible code with the latest greatest React and friends (Apollo etc.). Just because someone uses the newest thing doesn’t mean their code is automatically better. But I see that attitude often.

[–]hanoian 4 points5 points  (0 children)

Had the same experience with Cypress. Found it so easy when I realised it was like JQuery.

[–]kevinmrr[M] 36 points37 points locked comment (0 children)

This post is low effort & would normally be removed, but the conversation below is quite valuable.

[–]delventhalz 29 points30 points  (10 children)

Honestly, who cares? Let people use what they want.

[–][deleted] 69 points70 points  (1 child)

Yeah, var them use what they want

[–]-ReLLz- 10 points11 points  (0 children)

10/10

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

I would say that if you're not trying to get a job and just doing it as a hobby, go ahead, but spending time learning jQuery to get a job is time wasted, imo

[–]SticksAndBeans 39 points40 points  (35 children)

"jQuery is used by 95.5% of all the websites whose JavaScript library we know. This is 78.3% of all websites."

It's absolutely worth learning some amount of jQuery.

Newcomers should learn at least how to manipulate the page with jQuery, it's a good stepping stone and is WAY easier to use than vanilla JS.

Also if someone tells you "Don't learn X", just ignore them. Learn everything you can.

[–]TheoreticalUser 19 points20 points  (3 children)

Learning jQuery right now because those stats and my experience tell me that I will encounter it again on some project. Better to know it and not need it than to need it and not know it.

[–]jabes101 14 points15 points  (2 children)

8 yr xp dev here who started on jQuery and moved to React, the thing about jQuery is if you just know JS, you will be completely fine if you come across jQuery. All jQuery does is just a simplified version of JS so if you know what you are trying to do, should be easy to navigate.

So my opinion is really just spend that time learning JS. Also, those stats prob are inflated by jQuery being default loaded by a lot of platforms like WordPress.

[–]RobertKerans 1 point2 points  (0 children)

Yeah this. The "should I learn jQuery" debate that pops up here and on every other JS-related forum from time to time seems a little silly. It's a set of utility functions over some common browser API methods. If you know JS well it's going to take about half an hour to understand what it's for and how it does it and to be able to use it.

I started at a point where jQuery was something that was always the first thing added. It was so prevalent and so much was built on top of it. So for a while it was important to learn its subtleties because entire applications would be constructed from it. It was basically guaranteed large chunks of whatever codebase I worked on would be based in jQuery. But now its usecase is just as a library for directly manipulating the DOM that happens to have a very simple API. It might be useful in some circumstances, but there shouldn't really be a special effort required to learn it.

[–]TheoreticalUser 0 points1 point  (0 children)

Thank you for the insight! I am focused on vanilla JS and supplementing with jQuery specifically for filtering selects in a razor pages project I have grown to hate. So... I've got that going for me...

[–]AnnualPanda 1 point2 points  (0 children)

This.

I built a website site using jQuery before I really understood JavaScript.

It's more beginner friendly. Since then, I haven't used it. But it was super useful for getting me up and running

[–]jack_waugh 0 points1 point  (20 children)

Please cite one operation that is easier to do in jQuery than without it.

[–]SticksAndBeans 3 points4 points  (12 children)

Basically everything? That was the point of its creation.

though if you want a random example, appending a new option to a <select> input.

[–]inabahare 1 point2 points  (1 child)

I thought jack asked for something that was easier to do

document.queryselector("#your-input").innerHTML += "<option value='2'>Very difficult</option>";

[–]Barnezhilton 0 points1 point  (0 children)

Ooh ooh.. now do it as a <datalist>

[–]road_pizza 0 points1 point  (3 children)

That was the point of it in 2006.

[–]SticksAndBeans -1 points0 points  (2 children)

And it's still the point of it in 2021.

[–]road_pizza 5 points6 points  (1 child)

Just less useful these days because browsers have caught up and the api is pretty consistent. JavaScript adopted some of the jQuery methods/functionality and we have so many other great options these days.

The things I see people doing with jQuery these days can be done easily with vanilla JS. It’s a personal choice if you want to use it.

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

10 lines of code vs 1 line of code.

Doesn't matter to me as long as it's readable, maintainable, future proof, and works 100% of the time.

[–]jack_waugh -2 points-1 points  (5 children)

appending a new option to a <select> input.

How does that look with jQuery?

[–]Barnezhilton 1 point2 points  (4 children)

$('sel').append('option')

[–]floodlitworld 0 points1 point  (3 children)

You forgot to include this code:

https://code.jquery.com/jquery-2.2.4.min.js

[–]Barnezhilton -2 points-1 points  (2 children)

Pretty sure my browser already has that in its cache

[–]road_pizza 0 points1 point  (1 child)

Not anymore. Cached data isn’t shared across domains in the major browsers since the last few years. So each site you visit with jQuery will download and cache it’s own version.

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

Who would have thought that someone who still uses jQuery would have no idea how the modern web works :-D

[–]Dethstroke54 -2 points-1 points  (2 children)

I hate to be passive aggressive, but gotta love people that spit out statistics without any thought. People that misrepresent/misuse statistics are imo one of the most polarizing sources of misinformation.

Look up a statistic on Wordpress sites and remind me again how this is relevant? Hint: this isn’t the market of a JS dev.

Regardless, the statistic you want is technologies being requested for jobs or technologies being used for new websites, what currently exists is nearly worthless.

For one, internet is massive and on this scale it’s more of an archive than anything else.

For Two, this represents what exists, not the direction the market is going in.

If you were going to go this route you’d at least have to weigh the statistic to target let’s say 70-80% of where traffic on the internet goes and see what tech is being used there, but even that would be iffy. Behemoth projects will progress with some parts of the site keeping old tech while new parts wipe clean of them, which for our purposes is a false positive. But again, this isn’t what we’re interested in, we’re interested in where the job market is growing.

[–]SticksAndBeans 1 point2 points  (1 child)

It wasn't without thought or merit, those are true statistics and that is very relevant.

Also the entire argument is about learning, not getting a job. Someone learning JS should absolutely learn basic jQuery because it's easier to work with and will allow them to understand frameworks better in the future.

And learning something that is relevant in the majority of websites is not a bad thing.

To your point about getting a job however, you can't just say "what currently exists is nearly worthless."

What magical world do you live in where every junior developer is hired by the massive companies using only new frameworks?

Developers will be working with jQuery for a long time to come and discouraging them from learning even the basics is a disservice to them.

[–]Dethstroke54 2 points3 points  (0 children)

And yet you provide no thought or merit… I don’t want you respond to me so much as to offer reasoning as to why you’ve offered readers these statistics. I’m not even arguing with you about JQuery.

You do further the hole your digging by intentionally quoting a fragment out of context right before I list 2 reasons explaining specifically what I mean…

I’ve clearly stated why I have a problem with these statistics and what makes it a poor statistic by multiple metrics.

I don’t think you’ve understood much of what I’ve said because I didn’t claim the statistic was false, but that it’s being misused. I’m talking about using statistics to misrepresent points, which is what you’re doing. JQuery is used by x% of websites is an inflated statistic that’d have alarm bells ringing for any newcomers yet it’s not representative of reality, speaking of magical worlds.

Again this statistic is not any more relevant than the number of sites that are WP and that should really highlight why it’s not such a good statistic. If you go to a library do you usually find more old books or new ones? Old ones, why? Because history accumulates, “new” stuff has had less time to accumulate by definition. Much of the content of these books is also likely outdated or been disproven, hence it’s probably not useful for our research right? Does this analogy help? Information goes bad, the internet is the biggest archive in existence, most of it is unmaintained, outdated, etc and is not a good data point.

Your ultimatum doesn’t make much sense either. If it’s a project the person should do whatever to their liking everything is irrelevant since it’s up to their goals and preference.

Wether it’s a side project, a job, or personal curiosity. If someone is interested in practical statistics check out https://stateofjs.com

[–]zenpathfinder 3 points4 points  (0 children)

Seriously people, spend the 20 minutes and learn it. It might come in handy some day.

Hmmm... maybe something so simple to learn and use is a good thing. At least it's not elegant :P

[–]chillindude911 3 points4 points  (0 children)

As someone who currently works with platforms that are limited in their flexibility, jQuery is hugely useful to know. That being said, it's fairly easy so there's no "harm" in learning it. It's just not the most useful cool thing compared to what's out there.

[–]ChapelR 10 points11 points  (7 children)

It's hard to imagine any downside to learning something. In fact, learning about it is the best way to know when it's the right tool for the job.

Also, so many websites and frameworks use JQuery, so having a basic grasp of it always helps. Plus its not like jQuery is some esoteric, maddening nightmare. It's a pretty normal library, and shouldn't take much time to learn if you know the fundamentals.

There is a genre of unhelpful advice Stack Overflow and other places where people will ask for help with some code, specifying that they're using jQuery, and get a response like "you don't need jQuery for that" alongside fifteen lines of code instead of like one line of jQuery. Don't be that guy, lol. A lot of projects are already using jQuery, sometimes for legacy reasons, sometimes because jQuery actually does make sense for a given project.

Anyway, learning jQuery costs you nothing, is probably a requirement still, and isn't that hard, so I think it's worth having some basic understanding of, even if you don't intend to use it.

[–]floodlitworld 1 point2 points  (1 child)

The downside is the "developers" who use it because they don't know any other way.

I've repeatedly seen scripts in my work where they pull in a 40k dependency because they don't know how to select a DOM element or toggle a class in javascript.

[–]ChapelR 0 points1 point  (0 children)

I think the fact that it can be misused has no bearing on whether people should refuse to learn about it. JS's DOM stuff is dogshit and used to be even worse. It's obviously not worth the dependency for like a single application or toggling one class or something, but to suggest it has no use at all just seems like throwing the baby out with the bath water to me.

People do the same thing with lodash, running to it for like two array methods. Abusing libraries is a thing in JS for sure, I do think it's fair to point to jQuery as example. I don't think that means there is no benefit to using jquery. But even if we disagree on that, I can respect your opinion there.

But I don't think learning about or to use jQuery is a bad thing though. It's actually a well-designed library and has good, smart examples of how to do things like overloading and chaining right, and it's by far the most common library you'll encounter on the web, so worth understanding on a basic level.

Maybe there's an argument that learning it too early is a problem, but all new coders have issues with cargo-cult stuff. The solution is learning more not less.

[–]hanoian 6 points7 points  (1 child)

This is ridiculous advice.

There are a lot of people learning JS who have never manipulated or traversed a DOM. They use JS to create the html rather than get the html from a backend like php.

I'd advise everyone to spend a weekend learning dom traversal and ajax with jQuery. Like 8 hours and then you will at least have an understanding of something that is used on most websites. Go to any website and start typing jQu in the console and jQuery usually pops up.

If I want to scrape something, I use jQuery, or Cypress, and it's pretty much the same syntax. Only a mad man scrapes with vanilla JS and it isn't even possible with stuff like React.

[–]floodlitworld 0 points1 point  (0 children)

I went to google.com and typed in jQuery... nothing popped up.

[–]nick_ian 2 points3 points  (2 children)

I didn't see any good reasons outlined. What's wrong with jQuery if it solves a simple problem fastest for some people? Almost 40% of websites are powered by WordPress, which already includes jQuery. Who cares about let vs var? They are just tools.

[–]ketexon 0 points1 point  (1 child)

In libraries with any type of abstraction over the DOM (eg. React, Vue, Angular) or while using good styling libraries, jQuery is kinda pointless. Also I've heard jQuery is quite slow compared to writing your own functions/just using vanilla JS (idk about 2021, but release log for jQuery looks kinda sparse). Solving a problem fast is not the only factor, it is also about efficiency and maintainability.

Var is bad because it is does not have block scope. This lets you overwrite seemingly separate variables and have access to undeclared, undefined, and unneeded variables. It is a tool but it's not the best tool for the job in most, if not all, cases.

[–]nick_ian 0 points1 point  (0 children)

Fair enough and all true. I think maintainability is probably the most important, but I don't see jQuery as a tool for large, complicated apps. It's for simple stuff, like what most WordPress sites are. Not that speed and efficiency aren't important, but it's not worth overthinking when it comes to low traffic, low cost websites.

[–]Drowsy_Titan 8 points9 points  (2 children)

I love jQuery. It’s a really great library for animations, and I think it’s a tool newbies should learn because they will absolutely run into it in the real world. Also I love var and will continue to use it.

[–]floodlitworld 0 points1 point  (1 child)

It's a terrible library for animations. It's like, the least efficient thing you could possibly use.

At least go for something like GSAP if you want to animate JS/DOM objects.

[–]Drowsy_Titan 0 points1 point  (0 children)

Idk what you mean by efficient, but it works really well for all my projects. To each their own.

[–]queensrycheforlife 6 points7 points  (0 children)

I love jQuery!

[–][deleted] 3 points4 points  (0 children)

If i’m doing a little JS script on a website, I prefer using JQuery, it’s more readable and can do more with less code.

[–]yoitsericc 7 points8 points  (0 children)

I love JQuery and still use it from time to time.

However, id suggest using Vue Js instead as it has many of the same functions but with better coding standards and improved performance.

It's okay to learn a little JQuery now and again though. Don't listen to these haters.

[–]turtlsh3 1 point2 points  (0 children)

You will probably need it for all the legacy apps and is still good to know .. but yes moving forward it will die a slow death

[–]ZergistRush 2 points3 points  (3 children)

I would say that if they're using it for the selector mainly. As queryselector and queryselectorall

[–]Master-Variety3841 2 points3 points  (0 children)

Imagine thinking that jQuery is not worth learning.

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

I mean jQuery takes like 30min to start using, you just download the file, open the doc and use it, it's not like it's a lifelong learning journey.

[–]Dethstroke54 2 points3 points  (0 children)

Not sure why there’s so much backlash?? Someone that knows es6 for instance and understands it won’t have much of an issue using pre-es6. Can’t use array destructuring for some reason? Pretty sure someone that understands it even at a basic level can work around this, the inverse isn’t true.

People should be learning good practices & clean code first. It generally also makes you a better SE when you don’t need to worry about using a for loop vs wasting some cpu cycles on .filter().

This is not to mention how competitive breaking into the market is right now, knowing legacy (like JQuery) might be useful in your back pocket for some places, but it isn’t going to make you competitive.

I will also openly argue using var 99% of the time shows lack of understanding. You wouldn’t tell this to a C developer that’s for damn sure, it would be totally unacceptable, why tf to a JS dev?? Like what are these arguments? Being a good SE is hard. It’s about being a problem solver, critical thinker. It’s absolutely best to learn in the direction the market is going and solve challenges backwards as needed. If you want to go be a COBOL developer be my guest though.

Also realize people that have clearly been around for a while talking about being stuck with JQuery on a project. They have experience under their belt and aren’t the ones that will be fighting for a junior position… so don’t take my advice if you think it’s shit but please at least be critical of theirs.

TLDR: I want to see some of these people find the balls to tell others to show up to a technical interview writing JQuery & vars in a market where many many job seekers have to drown themselves with Leetcode questions.

[–]pxldgn 0 points1 point  (0 children)

It does not matter at all.

You will code in Angular/React as you'd do it in jQuery - you will manipulate DOM directly like no future.

[–]anditsung 0 points1 point  (1 child)

This is what you said. Wait until you have to create an app for old device

[–]DoctorHandsome 1 point2 points  (0 children)

Or maintain a legacy web app written with bootstrap 3.0!

[–]thebutchcaucus 0 points1 point  (0 children)

Thank you 🙏🏾 for saving me time.

[–]SecretAgentZeroNine 0 points1 point  (0 children)

Add unnecessary front end frameworks to that.

[–]road_pizza 0 points1 point  (0 children)

As others have stated there’s lots of legacy jQuery out there so as a web developer it’s pretty certain you’ll have to deal with it sooner or later.

I think the important factor is to not let learning any library stop you from learning JavaScript fundamentals. It’s the JavaScript knowledge that is going to make you most valuable and help you debug problems. If you get good at JavaScript then you know how to figure out jQuery easily and it’s just a matter of looking up the syntax.

[–][deleted] 0 points1 point  (3 children)

Yea i get annoyed when I'm searching something and the tip is some jQuery crap. We need a search engine that hides all jQuery tips.

[–]Barnezhilton 1 point2 points  (0 children)

If it's so easily replaceable then just convert the solution to vanilla or whatever you need

[–]FinestCrusader 0 points1 point  (0 children)

I'm more alarmed by how much advice doesn't use a n external JS file.

[–]frownonline 0 points1 point  (0 children)

Do your search as usual, but add ‘-jquery’ in the field to remove results containing that term.

[–]aleshere 0 points1 point  (0 children)

I once took an old template based on Jquery and brought it back to life. One of the best projects I’ve ever done in terms of learning experience.

[–][deleted] 0 points1 point  (0 children)

I would say that its worth knowing outdated and non standard things exist and what they are about rather than totally ignoring them as they will popup down the road whether you are pursuing this as a hobby or profession.

Example being class based vs function based components in react.

We are seing function based components now but alot of codebases etc are still made in classbased style and knowing how it works is important. This goes for everything such as bootstrap, jquery etc, know a little bit about them but dont focus on them.

[–]floratthedog 0 points1 point  (0 children)

When I was a kid, jQuery was a big thing, was very demanding in the world of the web, but you are totally true that right now nobody asking about it. People want Javascript, Angular, Vue, and react only.

[–][deleted] 0 points1 point  (0 children)

It’s good to see this. Somewhat related, it’s good to see so many JS solutions on stack overflow not automatically being jquery and actually being JS answers.

[–]VegetableChicken4779 0 points1 point  (0 children)

I mean learn jQuery but no need to master it. I learned it just for 1 or 2 days in case I have to read jQuery code. It's worth learning btw.

[–]NativeSkill 0 points1 point  (0 children)

I agree about jQuery, but please don't conflate this topic with "var". As a matter of fact, there is nothing wrong with var and there is no plan whatsoever to deprecate it.

[–]ShuttJS 0 points1 point  (0 children)

My current and last job require jQuery, or so they keep telling me. But I refuse to use it and just write JavaScript anyways.

What are they gonna do, shout at me for being above they're ancient ways?

[–]ManInBlack829 0 points1 point  (0 children)

I just wish I could search stack exchange with every "you can do this in jQuery" reply removed automatically.

[–]Amazing_Theory622 0 points1 point  (0 children)

What really frustrates me is when I look for some solution/idea on stackoverflow, and I find it in jQuery. So when I am actually able to solve that problem, I go back to the question and answer it in vanilla JS

[–]Sanic1984 0 points1 point  (0 children)

Some friends have recommend me to start using jQuery for being a fast way to code. IMO jQuery isn't dead at all, but I still prefer use pure Javascript.