I think jQuery is a much needed library, but I don't understand why so many developers hate it and try to replicate the same functionalities with plain JavaScript.

For example, take a look at this repo. It claims we don't need jQuery and explains how to replicate each jQuery feature in plain JavaScript. Well, what's the point? jQuery exists to make your life easier - why reinvent the wheel?

What do you think?

Write your answer…

11 answers

When jQuery was the new thing, people loved it. It made cross-browser JS so much easier, it taught us a few new tricks, it made AJAX and animations dead simple (which was pretty tricky back when most of the world were on IE6!)

It evolved a not-to-be-sniffed at plugin community and immense mind-share. It became the de facto client-side Javascript library for years.

Those were the heady days of jQuery's heyday and it gained a lot of weight as it spent its popularity on better support and more features.

Also it attracted a lot of mediocre developers because it was seemingly 'easy to use'. This resulted in a lot of terrible Javascript being written and much debate between so-called pros (although there's nothing professional about berating newcomers) about the merits of using a library which they saw as being the lightning rod for all this bad code.

Then came The Smartphone Times. This spelled disaster for jQuery: thanks to slower, inferior CPUs, less memory and often less bandwidth, smartphones just weren't cut out for lugging around all the goodness that jQuery provided - especially if you were only using 10% of it.

This meant that a deep analysis of jQuery's internal elements went underway to see how things could be more modularised. And as we headed into the Golden Age of web development, many realised that the browsers have started to agree on some of the crap that jQuery The Negotiator had been helping them with all along. So they actively and rapidly trimmed the fat.

During this modularisation stage, many factions split off from jQuery to create super-tuned, single-purpose libraries that were extremely lightweight. They could still work everywhere (mostly) and they didn't eat up people's 3G/4G data allowances. They also performed better than jQuery in the browser in some cases.

Also in the background, the Javascript Revolution was happening seeing this 'little browser language' become a full-blown, server-side programming language. And this highlighted that jQuery was very much a client-side, DOM manipulation library, skills which weren't so transferrable to the server-side application style of programming.

Besides all of this, jQuery gained some younger, better-looking cousins/distant relatives (Angular, React etc) which tackled similar problems to jQuery in altogether new and intuitive ways. And on top of that, these new relatives started pushing to use the latest Javascript APIs, seeing super increases in performance thanks to newer browser support, while jQuery hung back making sure its feature-set worked in as many browsers as it could consistently for as long as possible.

But don't write jQuery off just yet. It will be 10 years old next year. In internet years that's approx. 1,000 years old. But look, jQuery is still going strong. Sure it's not as slick and fast as some of its younger cousins, but it still got some moves they don't do. And for those of us who remember why jQuery was the shiznit, we still got some deep respect for it and may still use it for convenience.

jQuery made a mark on client-side Javascript like no other and ushered in the Golden Age. But sometimes you gotta walk over the bones of the dead to get to the future...

1 Beer1

Hashnode is building a friendly and inclusive dev community. Come jump on the bandwagon!

  • 💬 A beginner friendly place

  • 🧠 Stay in the loop and grow your knowledge

  • 🍕 >500K developers share programming wisdom here

  • ❤️ Support the growing dev community!

Register ( 500k+ developers strong 👊)

jQuery (and GWT actually as well) was created to overcome the big issue we had not too long ago where something that would work in one browser didn't work in another browser - JavaScript was painful to work with and jQuery came to the rescue.

Fast-forward a little bit and you see that browsers are becoming more and more standards compliant which means jQuery is no longer needed to solve that original pain. For probably the same reason GWT was abandoned.

So those who hate jQuery obviously didn't have to deal with JavaScript in its infant stages, those that did will have somewhat more respect for it and thank it for its great service over the years even if they're no longer using it.

I completely understand the complaint about jQuery being the 'lightening rod' for some really bad code and practices.

All the same, for me it boils down to choosing the right tools for the right job at the right effort/price level. I'd happily use this battle-hardened library (jQuery) for quick traditional web projects.

Show all replies

How edgy Steven. You must be one of the pro developers. As Justin said 2 years ago (!!) jQuery is a battle-hardened library, and it's asinine to recreate the wheel if a perfectly good one already exists.

Reply to this…

Whenever something gains great growth there comes a point where people will decry it simply because they want to use the next new thing. Jquery is still widely used. Its a tool. Javascript has evolved and there are many things that can be done easier than in the past, but there are still times where you can do it with less code in jquery. Every new library or javascript framework goes through this cycle. Right now as popular as Angular has become people are already complaining about its shortcomings or how it clutters and breaks conventions. You also see this with CSS as things like flexbox make people question whether you need a responsive css framework like Bootstrap or Foundation. This is the up and down sometimes manic depressive nature of web development.

Another factor influencing this trend away from libraries is what I call "the smartphone effect". Smartphone's made the push for minimizing page size as big a deal as it was back when people used modems and isdn. There was a time right before smartphones when bandwidth and browsers were really picking up steam. Suddenly loading larger pages with more features and bytes wasn't that big a deal. We didn't have to worry so much about slower internet connections and bad browsers (well except for all the IE variants). Unfortunately once smartphones grew in popularity that problem cropped up again. Suddenly the world of web development had to take a step backwards because browsers on smartphones were not as robust and we had to deal with slower cellular connections. Keeping your page size to a minimum was always important, but it became more critical again with smartphones. This is one of the reasons there is a push to use native javascript, native css etc because it keeps things lightweight and contributes to a faster loading page. With that said, smartphones and tablets have really improved a lot over the last few years. They are faster, the browsers are improving and connections are getting faster.

Its always good to know how to work with raw js without a library. If all you know is jquery that's not good. There are many times where you may only need raw javascript even though you may be using jquery. Also be aware that you don't need to load the full jquery library. These days its easy to create a package just with the features you need. There is nothing wrong with using jquery or other libraries. Just be mindful of your target audience, your page size and load times. Optimize images and try not to be dependent on too many plugins.

With time, we learn what is good code and what is not. Since Node.js, we have developed promises to something real. jQuery rejects to become Promises/A+ compliant - they say they can break the web when changing its behavior (why do they develop 2.x?) With Node.js and a bit React.js we have understood globals and treat them now a bad thing - hey Browserify users, globals are a BAD thing! :-) Web performance matters and yet jQuery rejects to be a modular library like lodash is. This is a problem. Some people use jQuery just for selecting elements in the DOM or doing Ajax but nothing more what jQuery has to over. 84kb for selecting elements and/or Ajax is anything but smart. jQuery does not help to structure code. Spaghetti and jQuery is a de facto unbreakable word combination.

The so often mentioned browser compatibility is a legend from the past. Why should Chrome and Firefox load jQuery to fix looping behavior when only old IE needs to be fixed? We have shims and polyfills, applied selectively if requested. Nginx can parse HTTP headers and rewrite URLs to load shims for the correct browser only.

For me, jQuery was great back in the times when IE6-8 has terrorized us and Firefox as well as Chrome interpreted JS differently, compared to each other. But things have changed fortunately and I can't find any reason why we have to keep this dinosaur alive.

jquery 2.0 has removed all that cruft to deal with IE.

Reply to this…

Load more responses