In Defense of jQuery

Christian Schlensker
2 min readMar 11, 2019

I was just reading (a.k.a distracted by) this Reddit question: “Why do many web developers hate jQuery?” and the discourse I saw in the thread inspired me to write something.

jQuery has design benefits and drawbacks

I think it’s biggest design benefit and the one that lead to it’s huge adoption is also the same reason it’s hated so much. That benefit is its priority on being easy to use. What jQuery did that was so amazing is that it took the problem of DOM scripting, something that was traditionally very difficult and foreign to a lot of people, and wrapped it in an API that was easy and familiar. All of the sudden, manipulating the DOM was as easy as using CSS selectors, and the ability to create impressive experiences was only a few plugins away.

However

One lesson that one often learns after they’ve been programming a while, the same lesson that’s covered most excellently by this Rich Hickey talk, is that things that are “easy” in the short term are not always the most beneficial in the long term. When working with large applications or long term architectural and scalability concerns, “simplicity” is much more valuable and ultimately makes work “easier” in the long run than the quick wins granted by the “plugin culture” of the jQuery community. Under those scenarios, it’s probably better to choose a tool that’s optimized for those problems.

Furthermore, vanilla DOM scripting has gotten much easier, so a tool like jQuery is far less valuable than it used to be and having that extra dependency may not be justify the complexity cost. It’s just lamentable sometimes that the native browser APIs still don’t seem as streamlined or terse.

What is this tool optimized for?”

Takeaway:

I think as software engineers we frequently fall into the trap of over generalizing and applying absolute values to situations where they may not be appropriate. When evaluating a tool it’s best not to think in terms of “is this tool good?” or “is this tool bad?” but instead think about “What is this tool optimized for?”

A tool like jQuery is optimized for ease of adoption and rapid impact so might be good for a small or short term project

A tool like React is optimized for scaling large applications but might be slower to get started with or for rapid prototyping.

The professional developer’s task is to figure out what scenario they are in and then find the best tool for that job.

--

--