This question is a serious question for anyone who believes there is still just as much importance in understanding the core JavaScript language, even in the post-jQuery world.

In the last seven years, I have followed the development of jQuery and truly appreciate what it does for developers. I have always appreciated writing modular and reusable code like jQuery, as someone who has continuously developed JavaScript applications for 14 years. Everyone who used JavaScript in the pre-jQuery days knew how useful it would be to have a standard JavaScript library that did common things well, and the amazing popularity of jQuery showed just how real that need was.

But it is nothing short of scary to see the unexpected negative side, particularly, the detrimental effect on the overall skill level of programmers.

Some JavaScript programmers with six years of tenure or less are spending more and more of their time learning jQuery, gaining less and less knowledge and understanding of the JavaScript it is based on.

Not long ago, a polished final product was one that contained a small script doing exactly what was needed, although in development it might rely on 10-100 KB of jQuery code with the associated network overhead. But just the opposite is true today. jQuery seems to be an artificial requirement for almost any project large or small, and I shudder every time I see a JavaScript program rely on jQuery when there is no reason.

A perfect example of how bad the problem is: How can I make a redirect page in jQuery/JavaScript?

Already in just six years, I sense a preference for any solution that uses jQuery, even if it actually takes more lines of code to implement in jQuery than in native JavaScript! Worse, there even seem to be a few who automatically consider any code not using jQuery to be suspect.

I am concerned that the same thing will happen with JavaScript that has happened with knowledge of CPU instruction sets, machine language, etc. It is not too much of an exaggeration that if a select group of 1,000 people disappeared, no one else in the world would know how to continue the development of computer chips, and society would change drastically. Web development could certainly reach the same point within 15 years if the knowledge of core languages is not preserved at the level of popular "consumer"-level use.

Is there a way to define a dividing line between appropriate and inappropriate uses of jQuery? And how can we who answer stackoverflow questions begin to observe that dividing line for the sake of the long-term preservation of JavaScript knowledge in the next 15 years of this important programming language?


migrated from Apr 21 '14 at 13:49


Perhaps you'd like to have us all ditch Gnome/KDE/Qt as well and revert to direct X11? Or give up the Java collections classes and use C arrays? Or throw away our high-level languages altogether and return to assembler? :-) That may seem a fatuous comment but it's not. The whole point of things like jQuery is to make things easier. I can't see the problem of using it. –  paxdiablo Apr 26 '13 at 5:36
Do I need to move this to Meta Stack Overflow? I thought that MSO was for account questions, using the Q&A sites, etc. But I can move it there if that is the right place for it. To me this is a programming question even though its about programming rather than about a program, but I'll be happy to move it as the community sees fit. –  Joseph Myers Apr 26 '13 at 5:37
@Zeta I don't see this as a meta question, just a programming question that happens to be about the people using the programming language. –  Patashu Apr 26 '13 at 5:37
so we should all program in machine language, is that what you are saying? the information might be forgotten. it is same with spoken laguages. latin is forgotten, english is now the primary language. this will happen. you can't do anything about it. –  btevfik Apr 26 '13 at 5:45
@btevfik, linguam latinam est non oblitus !! –  paxdiablo Apr 26 '13 at 5:48
I'm not saying by any means we should all program in machine language or use pure X11 interfaces. In fact, I did my best to express how useful and good jQuery can be. –  Joseph Myers Apr 26 '13 at 5:48
@paxdiablo name one nation that speaks latin. –  btevfik Apr 26 '13 at 5:50
@btevfik, that was meant to be humour. However, I don't consider a language dead just because no country has it as an official language. There's a rather large part of Catholicism that still uses Latin and, if you know a bit, it's a heck of a lot easier to translate between any of the Latin-based languages. Still, I didn't come here to argue in comment boxes, so I'll leave it there. –  paxdiablo Apr 26 '13 at 6:01
What is this JavaScript you keep talking about? It's some kind of predecessor to jQuery, right? –  Pekka 웃 Apr 26 '13 at 6:24
Obligatory: (Extracted from previous link for immediate access to hilarity) –  J. Steen Apr 26 '13 at 7:10
2… –  Florian Margaine Apr 26 '13 at 13:39
+1, I've never used jQuery, and I don't see why it's hyped. I prefer simple web designs and as few JavaScript as possible. –  Calmarius Apr 26 '13 at 16:00
From what I'm personally seeing, a lot of people are "learning jQuery" and don't know how to use JavaScript. The use of jQuery is also simplifying the complex parts of scripting that need to be learned to fully understand parts of the language. People are learning shortcuts instead of learning proper usage. –  hexacyanide Apr 28 '13 at 23:34
BTW, machine language was not a good choice of words for me to use because those words were set up as a "straw man" and attacked rather than the point I was actually making. (Straw man: A straw man argument is an informal fallacy based on misrepresenting a position so as to more easily refute it) Putting an emphasis on the importance of knowing JavaScript rather than only jQuery is not like asking everyone to learn machine language. –  Joseph Myers Apr 29 '13 at 0:11
This isn't just limited to javascript. A few months ago I was criticized for writing 10 lines of Socket code when I "could have used a message queue instead". Never mind that adding a message would have required a whole new server with the associated configuration headaches, not to mention probably twice as much code to use it. –  Warren Dew Apr 27 '14 at 6:35

6 Answers 6

up vote 38 down vote accepted

While I am a strong proponent of JavaScript education myself, and learning how to get stuff done without relying on thousands of lines of external code...

Let me play the devil's advocate.

Let's say you're writing an application that has to only run on modern browsers (old IE support is a big selling point for many) . It is fairly simple and involves mainly basic dom manipulation. I argue that as an inexperienced developer you would still be better off using jQuery. Shocked? Here is why:

  1. jQuery is very well documented. Every single method in jQuery is well documented. The documentation is very good, there are plenty of examples and plenty of code demonstrating those examples. For example, a google search result for "javascript click" yields this badly written JavaScript link as the first relevant result (4th total) but "jQuery click" leads to the this page which is full of useful examples

  2. jQuery makes animations easy , it is very appealing to use jQuery to create animations, it is certainly a lot easier than to do with the DOM. You don't have to understand how stuff works to write something like myElement.hide("fast") and have it 'just work'

  3. jQuery makes AJAX easy . Yes, I know AJAX is fairly straightforward in JavaScript, but $.get $.load and $.ajax are very easy to use, easier than listening to readyStateChange events and shorter to write. The example pages are very documented

  4. You need to know very little to get things done . With jQuery you don't need to really understand how the DOM, stuff like event delegation are just 'done' for your ease. Sliding, toggling, adding elements, getting ancestors etc. is very easy.

  5. StackOverflow has lots of simple, short jQuery answers A lot of times, when googling for how to do something in JavaScript a StackOverflow answer with jQuery code comes up, making solving stuff easy. We're actually encouraging jQuery without always meaning to.

(Plenty of other such good arguments, it's almost everywhere anyway, the API is easy to use and get into, plenty of cool plugins, easy support).

So should we encourage jQuery?

NO . While jQuery is a useful library, it is our responsibility as a community to encourage developers to be better. We're creating the next generation of our own co-workers. We should try to encourage understanding where we can.

So what can be done:

  • When answering a jQuery question, offer an alternative JavaScript vanilla solution. Take your time to really explain it, how it works, and why. Explain how jQuery does what it does and why it might be a bad option in this case.
  • When asked JavaScript questions write answers that link to good resources such as MDN, add examples and good practices. Explain why everything works. SO is in charge of a large portion of the documentation of JavaScript on the internet. It is up to us to make the language more accessible to people facing common problems.
  • When answering AJAX question explain how and why AJAX works the way it does, why readyStateChange works the way it does and the advantages of using it. As for animations while jQuery is a good fit in a lot of these cases it is far from a silver bullet, when possible and the vanilla way is relatively short - suggest it. When it is not there are plenty of other alternative libraries that do animations
  • Mention other scenarios in your answer, this will encourage the OP to try and understand why, and not just copy-(read through in the good case)-paste your code.

jQuery specific questions are usually (again, not always) the sign of a relatively new (again, not always) JavaScript developer. How we guide them really matters. The more we drive them towards better practices the better.

I have to partially disagree. Yes, it is kind of important that the user has a firm understanding of the underlying JavaScript, but in the particular case of JS/jQuery, seeing jQuery as a step forward, it's not that important. When you mention that might be effectively training our own co-workers, you forget that you do not want a co-worker that's good at the basics, but has no clue about anything beyond that. This is the same problem with with university people who did well in all the C/C++ exams, but have absolutely no idea how they would even begin with a non-stdlib (GUI) application. –  dialer Jul 14 '13 at 8:38
Your answer is really great, and I accept it. What you wrote has been growing on me since the time that I asked this question. I especially like how you give the list of benefits of jQuery as the "devil's advocate," and then conclude that regardless of all those reasons, it is our responsibility to have an existence at a higher level than the comfort zone in order to deserve the freedom of enjoying the comfort zone. This answer, exactly as you wrote it, is something well worth reading for all Stack Overflow JavaScript contributors and future JavaScript developers. –  Joseph Myers Jul 25 '13 at 21:46
StackOverflow has lots of simple, short jQuery answers I hope it's obvious how circular this is. –  torazaburo Aug 31 at 11:29

There are two kinds of programmers (no, this isn't that binary joke):

  1. Those looking for the lowest effort solution.
  2. Those who are mildly obsessed with finding the best solution (in pragmatic terms), and understanding why that solution works.

Changing the attitude of group #1 is a daunting task. I agree it's a problem, and it is prevalent in much more than JavaScript programming. You could make this argument about any language/platform/library, i.e. "it encourages mindless cut-and-paste, abstracts people from the 'real' issues, and builds an unbreakable dependency".

This issue reaches far beyond SO. From a SO perspective, I think the best way to counter this is to explain why something works, rather than spitting out a quick fix answer. There's also no harm in gently guiding people to "pure" approaches when appropriate. The accepted answer to the question you linked does just that.

Beyond that, if people want to give jQuery answers, so be it. The community is good about identifying when it does/does not make sense.

Group #2 is a completely different matter. I love jQuery not just because it made my life easier but because it emphasized how much could be done with a quirky-but-elegant language like JavaScript. I've written dozens of plugins since first using jQuery, some quite advanced. I've gone through the source code of jQuery numerous times, and dissected numerous jQuery plugins to learn more.

Many, many times, jQuery (or a similar library) is the right solution. This is a good thing. In the hands of a good developer, a library is a powerful tool; it enables them to produce more "goodness" faster.

Conversely, you can see that this same group of motivated engineers is still earnestly studying pure JavaScript. Browse questions around prototypical inheritance, object patterns, performance tweaks, etc. and you will see that interest in pure JavaScript is alive and well. I've been writing JavaScript for almost 15 years now, and some of the questions still are above me. I'm encouraged by that.

There is no problem with group 1! It's perfectly OK to want to know the quickest way to do something and not caring about it. Very often when coding JavaScript I look up what people did on StackOverflow just to see what alternative solutions/approaches there are. If I'm using jQuery (which is unlikely on its own) and already know how .on("click" works and I'm reading an answer using .click I don't usually need the explanation, more importantly, a lot of times people don't care. –  Benjamin Gruenbaum Apr 26 '13 at 13:39
I agree that is fine to look for a quick solution; I do it myself all the time and it's a great benefit of SO. In fact, part of group 2's strength is determining the most efficient way to get the job done. But if that's your whole approach to development, there's a problem. If someone knows how click() works, then they can skip the explanation...if they have no clue what an event is, maybe the explanation will make them think a little instead of just cutting and pasting the "magic". –  Tim Medora Apr 26 '13 at 14:56
The group 1 people makes me install NoScript. (Nowadays browsers are practically unusable when you have more than 5 tabs open, due to excess use of JavaScript and Flash...) –  Calmarius Apr 26 '13 at 16:09
I would argue that the lowest effort solution is the best solution. Being lazy is a quality when that drives you into DRY, KISS, avoiding overdoing or over-optimizing... If jQuery saves me 10 lines of js in 2 lines of readable jQuery calls, I can't think of a good reason to go for JS. –  njzk2 May 8 '14 at 21:26

This isn't a problem with SO, people just need to read the question a little more carefully. If it doesn't mention jQuery then don't answer with jQuery or if you are going to answer with it then just give reasons why you are suggesting it, e.g. "In some circumstances it allows you to only have to write 10 lines of code instead of 100."

This is also related to people trying to do everything with JavaScript instead of using the appropriate tools available to them. In particular people using JavaScript to modify Spring forms (read the answer's editing history to see original suggestions) and do funky AJAX submissions. JavaScript is great but it is not the right tool for every occasion.

Maybe there should be a function that strips out the "jquery" string in answers, when it's not mentioned in the question :D –  abimelex Apr 26 '13 at 5:50
Thank you. This is a very good suggestion that would be well worth following. I am also looking for discussion of how we can define this boundary in our own minds, of where the dividing line is, if any, separating when to use jQuery, and when not to. –  Joseph Myers Apr 26 '13 at 5:54
@JosephMyers, I guess that all comes down to how well you know JavaScript and its inner workings. Some people just want a quick solution and don't care how or why the jQuery works. And in the majority of cases that is what I seem to see jQuery get used for, its convenience. Everything jQuery can do, plain JavaScript can do. Probably with more efficiency for most use cases since you don't have to include a 90kB library. –  Ambrosia Apr 26 '13 at 6:22
@abimelex Excellent, I know a jQuery function that can do that. –  Super Cat Aug 9 at 0:40

I am guilty of doing this. For the following reason:

  • Jquery is pretty ubiquitous
  • It does remove browser inconsistencies

Even when handling simple events (a pretty basic / common think to do) we have multiple options of syntax. Then there are questions regarding e.g Array.forEach, only in ES5 whereas $.each is everywhere jquery is.

Just saves us time helping the people that need help quickly without explaining these differences to them every single time



I guess it is hard to define "appropriate".

However, the question you have shown shows the best thing the community does in this area: Voting the best solution to the top.

  • Answer #1 has nearly 3000 votes, and it shows the advantage of using plain Javascript.
  • Answer #2 has nearly 300 votes (only 10% of #1!), but also tells the disadvantages of it, and in comments it is heavily discussed.

So that's what you can do: Comment answers with jQuery if you think it is "better" do be solved using pure JS and why. Also post an answer where you show the advantages of pure Javascript.

What I can see in your question is your opinion: "People should learn Javascript before learning jQuery!" I don't think so. I myself started learning Javascript and used jQuery very soon. And once you are using it longer, and you are willing to learn, you will also learn how the Javascript below works.

Someone how does not care "how" it works will not learn Javascript anyway, neither by starting using plain Javascript first or using jQuery first.


Could we simply tag the questions with [pure] or specifically [no-lib] when appropriate?

Also, [no-stl], [no-std], [no-boost] for c++ etc.

This could also be a new feature in SO / SE to automatically colour tags with prefix 'no-' in red.

... just tag the question as [javascript] and not [jquery]. I for one, go ape **** ifi then see jQuery answers... –  Matt Apr 26 '13 at 8:30
Really, meta tags? You realize we are trying to get rid of these?! –  Doorknob Apr 26 '13 at 16:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .