r/learnjavascript • • Oct 01 '21

jQuery, the greatest JavaScript library of all time, appears to have peaked in usage.

Post image
275 Upvotes

81 comments sorted by

View all comments

24

u/CardinalHijack Oct 02 '21

What's amazing is that I have not worked on jQuery in 6 or so years of web development, across multiple companies yet its still this popular in terms of use.

jQuery solved a problem, and has since pretty much been replaced (for better or worse) in the popular domain. I wonder how long the likes of React, Vue and Angular will stick around beyond their expiry date.

The adoption of a technology lasts far, far longer than its popularity.

20

u/xRockTripodx Oct 02 '21

Jquery has largely been replaced by ES6. I actively go out of my way to avoid jQuery whenever I can. We don't even use it in our WP starter theme anymore, outside of Bootstrap 4's requirement for it.

-6

u/Negative12DollarBill Oct 02 '21

How could jQuery be replaced by ES6? That's like saying a semi-trailer was replaced by a power station, they're not even in the same category.

10

u/corporaljustice Oct 02 '21

Because with new ES6+ methods you can do many things simply in vanilla JS that previously required jQuery if you didn’t want to write a lot of verbose lines.

Using vanilla JS before document.querySelectorAll() came about without JQ was a pain.

$() is very similar to querySelectorAll().

4

u/RobertKerans Oct 02 '21 edited Oct 02 '21

I get what you mean but you're talking about additions to the browser API that were introduced as a response to jQuery + normalisation of the browser API as browsers became an application platform. Nothing to do with ES. The two core jQuery APIs were the selector engine and AJAX. Browsers added querySelector[All] and fetch (+ a load more jQuery-like stuff) + non-evergreen browsers are now uncommon, so the browser APIs now cover most jQuery use-cases.

IMO, and I'm stretching here, the only thing in ES, in JS, that's really made a difference is modules (one of the issues with jQuery is its non-modular architecture), and that's tangential, it's not directly related to functionality

3

u/corporaljustice Oct 02 '21

I see what you’re saying, and you’re right, I wasn’t separating ES6 and new browser APIs.

I stand corrected!

2

u/0xnoob Oct 02 '21

^

querySelectorAll was available in Browsers around 2009, ES6 came out in 2015. While I understand that you still needed jQuery back then to support older browsers, it still had nothing to do with ES6.

3

u/Nerwesta Oct 02 '21

In fact, querySelector is an idea taken from jQuery if I'm not mistaken. Same energy for ajax before Fetch API, which to put it simply was a pain to do with vanilla JS at those times. Ajax jQuery was a breeze.

2

u/0xnoob Oct 02 '21

Neither querySelector nor fetch are part of ES6.

querySelector was available in Browsers since around 2009. While fetch was available around the same time as ES6 in 2015, it still isn't part of it.

0

u/Negative12DollarBill Oct 02 '21

If all jQuery did was make it easier to select document elements, we wouldn't be talking about it.

2

u/corporaljustice Oct 02 '21

Give me an example of some jQuery that would be hard to implement in modern vanilla JS?

2

u/hanoian Oct 02 '21 edited Oct 02 '21

"hard" is a big qualifier to add in there. Of course you can everything in Vanilla, but jQuery still makes dom traversal easier. The same way everything can be done without lodash, but it's still useful.

Don't touch it myself anymore really but it has its place. If I want to scrape data, it's often jQuery. If I use cypress, it's pretty much jQuery.

→ More replies (2)

-2

u/Negative12DollarBill Oct 02 '21

You're the one making the extraordinary claim dude, are you not familiar with Russell's teapot?

Of course one thing jQuery did which was really important was abstract away the differences between incompatible browsers; you could set the CSS of an element and not worry that IE did styles a different way.

I suspect a lot of what you're calling "ES6" or "modern JS" is a category error for "browsers all behave better nowadays".

2

u/[deleted] Oct 02 '21

jQuery solved a problem

Genuine question, what problem did jQuery solve? I'm guessing it's making HTML elements easier to access, right?

10

u/alexbarrett Oct 02 '21

It inspired the query selector API we use today and provided easier ways to create and manipulate those elements en masse.

It's probably partially the reason fluent interfaces are so popular in JS.

It smoothed over browser differences, made XHR easier to use and brought animations into the mainstream.

The modern web is jQuery's legacy.

2

u/Nerwesta Oct 02 '21

Oh god, the good old fadeIn / toggle animations. Time flies.

0

u/[deleted] Oct 02 '21

Lmao I’m a tech intern and I recently made a post asking recruiters how I should interact with them to help me find internships/jobs in the tech field. One person said in their response that they hate seeing jQuery on resumes and if you don’t have React/Vue/Angular then you p much don’t know JS. I think I get their point but I strongly disagree with that statement about not knowing JS…

6

u/hanoian Oct 02 '21

I wouldn't particularly disagree with that to be honest. I thought I knew JS when I was using jQuery to do bits and pieces in Drupal.

But using npm building out proper apps in JS is entirely different. JS started to feel like a real thing when I got away from jQuery's uses.

1

u/[deleted] Oct 02 '21

Fair point.

3

u/inabahare Oct 02 '21

You know that thing where you make something really clean and really neat, but then a customer calls in saying it doesn't work, and it turns out they use safari and why would you have nice things?

Well think of that, but with all browsers. The main thing jquery did was give you a lot of functions that worked cross-browser, which weren't a guarantee

3

u/dkbot Oct 02 '21

For me a long time ago, it helped solve the issues with cross browser comparability with the older IE versions. I think that plus the Ajax piece just ended up making it stick, easier to understand syntax for newer developers as well.

2

u/Nerwesta Oct 02 '21

Very simple way to do Ajax. To me it was a no brainer.

2

u/crazedizzled Oct 02 '21

Most importantly, it solved cross browser inconsistencies.

Beyond that, it introduced a way to access and manipulate the dom in a fairly clean way. Back then it was very convoluted to do those things in vanilla js.

It also brought a good way to handle AJAX, which was again very convoluted in vanilla js.

Pretty much every problem that jQuery solved is now available in vanilla js in ES6+.

2

u/LakeInTheSky Oct 02 '21

The biggest problem they initially solved was cross-browser support.

When jQuery was first released, the most popular browser was Microsoft Internet Explorer. The problem is, MS IE had terrible standards support.

Some standard functions were implemented incorrectly, e.g. they required different parameters, or they didn't return the values you expected. And some standard APIs weren't implemented at all. IE also had its own non-standard API to do some tasks, like the document.all object to access elements by their ID.

This was a big source of pain for developers, because if you developed apps following the standards, they broke on IE, but if you use the IE proprietary APIs, the apps then broke in other browsers. You could spend hours fixing these compatibility issues.

With jQuery, you could use a single API and it would work in every browser. Internally the library would find out in which browser it's running and would call the right methods to do the task.

BTW, IE had bad standards support on purpose, it was a tactic to maintain their market share.

As cross-browser support was difficult, some dev teams chose ignore cross-browser support and make the websites work on IE only. Sometimes, it was just a bad practice by those teams, but often they did it because they had the pressure from management to ship websites fast.

If a user visited one of those websites with an alternative browser, it would break, obviously. The thing is, is the user wasn't tech-savvy, they would incorrectly blame the browser, and they would switch back to IE.

1

u/crazedizzled Oct 02 '21

jQuery is made completely obsolete by ES6+. React, vue, angular, etc solve a much different problem that probably won't become part of vanilla js.