loading...

Who still regularly uses jQuery?

ben profile image Ben Halpern ・1 min read

Lots of us are still using it for one reason or another. How about you? What's your story?

Discussion

pic
Editor guide
Collapse
sandeepbalachandran profile image
Collapse
vinceramces profile image
Vince Ramces Oliveros

One word. "Legacy"

jQuery shines the medieval era of web development.

Collapse
fcrozetta profile image
Fernando Crozetta

medieval era of the web development.

This is the most accurate way to describe those times.

Collapse
eddieaich profile image
Eddie Aich

Too many people are so eager to jump on the jQuery hate bandwagon. I'll say it - I STILL USE JQUERY.

Why?

  1. Some of my users are still on IE11
  2. Reduction in keystrokes
  3. Easier to implement drag, drop, and sortable
  4. I currently do not use a JS framework

With that said, I do use it sparingly and when I do, I make sure to indicate that a variable is pointing to a jQuery object:

$menuItems = $('.menu-items');
Collapse
dpashutskii profile image
Dmitrii Pashutskii

At least the first point you can change with Babel :)

Collapse
dyland profile image
Dylan Davenport

I still use JQuery for all of the same reasons 😅 I work at a non profit that caters to an older demographic so IE support is a necessary evil.

Collapse
thebouv profile image
Anthony Bouvier

Yup.

Cause not all of us over-engineer things by applying React or Angular to every bespoke 4 page website.

We have clients that are restaurants, bookstores, ad agencies, and otherwise and if you build out a 10 page website for any of those and decide setting up a complex frontend build system somehow makes sense for them, boo on you.

BootStrap 4 is super popular (and v3 still actually). It includes jQuery.

WordPress powers an insane # of websites and jQuery is included by default.

I've said it here many times in comments: you better have a great reason for choosing one of those frameworks. Otherwise, you're over-engineering and making a poor choice.

There are more websites/webapps that don't need those than there are that do need them.

Collapse
alangdm profile image
Alan Dávalos

I would agree that if anything the point of removing JQuery is because you can do most of that stuff with just vanilla JS, not that you need to begin using a framework

As you mention, using a JS framework for every static 4 page site is overkill, but adding a 30kB library when you can make without it is still plenty overkill IMO

There's a good reason why Bootstrap 5 is ditching JQuery 5 and just using plain old JS ;)

Collapse
thebouv profile image
Anthony Bouvier

I do agree with you on removing jQuery to replace things with vanilla js. I'll never argue against that unless you still have to support IE11 (and I happen to need to because on some sites I deal with I still get upwards of 10% of my visitors coming from IE11).

But: 30kb, what ever will we do in comparison to what gets downloaded with React/Vue/Angular and whatever monstrous sized files webpack creates?

Yet the state of front end dev right now will download 100+kb in fonts and let's not even talk about the image size people put out right now.

Or the friggin' ad network includes, trackers, analytics, etc.

There are a dozen other things to fix first in optimizing front end web page total download size than a single library. The average web page size in 2010 was 702kb compared to in 2016 which is 2232kb.

jQuery's size is hardly the problem. :)

Collapse
skydevht profile image
Holy-Elie Scaïde

Yeah, but jQuery and the like are very readable and consistent. Sometimes, jQuery may be too heavy, that's why I used a smaller framework for dom manipulation. But if it's there or there's no bandwidth issue, jquery it is.

Collapse
dmfay profile image
Dian Fay

I'm using it in new development right now and there's nothing you can do to stop me!

Collapse
dpashutskii profile image
Collapse
dmfay profile image
Dian Fay

It's a traceability and logistics platform using event sourcing in Postgres to maintain manufacturing, siting, and troubleshooting histories. The database and backend API are the important parts, while the web application is only one of several points of interactivity or interoperability. And releasing a functioning piece of software was/is more important than keeping up with the client-side Joneses, so to speak: this is essentially a one-woman production, and I don't have time to get as good with newer frontend techniques as I am with the stuff I've been working with since last decade. jQuery, server-rendered templates, and REST did the job well enough then and they do the same now!

Thread Thread
thebouv profile image
Thread Thread
dpashutskii profile image
Dmitrii Pashutskii

But to learn jQuery and check its documentation is much harder (in terms of time spending) than just use the Programming Language itself - JavaScript.

You don't need to learn any of modern techniques, you just need to know how to use the language without additional abstractions.
There is still the cases where doing something with JS harder than jQuery, but not so many.

I recommend to check youmightnotneedjquery.com/

Thread Thread
dmfay profile image
Dian Fay

Everything you've said is true! However, I do not need to learn jQuery, having learned it many years ago, and practically never need to reference its documentation since I'm not doing anything fancy with it. I am aware of document.querySelector and other such native functionality having become more generally available. I've used some of it in other projects where I was working with other people who knew this stuff well enough to make the call that we could do everything we needed without jQuery and ignore browsers that couldn't keep up.

I am not those people. This project might not need jQuery -- I would go so far as to say there's a good chance it doesn't -- but I'd much prefer to be consistent about using jQuery than the alternative.

Collapse
yuxufabio profile image
newbie

I'm learning Jquery in 2020! Hmmm..YEAH!

Collapse
bulsyusuf profile image
Bulama Yusuf

Hahahahaha... This one got me.

Collapse
matheuschimelli profile image
Matheus Chimelli

I don't use jQuery since 2017. Actually i use Vue on my projects since I stopped using jQuery. When i don't need to use Vue i use vanilla JavaScript.

Collapse
jackharner profile image
Jack Harner 🚀

I use it. 🙋‍♂️

  • Most of my work lately has been in WordPress and jQuery is built in.
  • $("#id") is easier to type than document.getElementById("id").

While I'm still learning more and more about React, I plan on eventually figuring out the setup for a React Frontend with a WordPress backend. Frameworks like Frontity make that connection a whole lot easier.

Collapse
alangdm profile image
Alan Dávalos

If you really just love $() you can add this line to your JS

const $ = selector => document.querySelector(selector);

or this one if you don't want to compile to es5

function $(selector) {
    return document.querySelector(selector);
}

And remove JQuery as it's overkill to have your user download a whole library if that's all you want XD

Collapse
afewminutesofcode profile image
Aaron

Thats a great tip Alan! I agree that it is overkill and I haven't used it for a number of years. I think when I stopped using it I became a better developer and got a much better understanding of js.

Collapse
mateus_vahl profile image
Mateus Vahl
const $ = document.querySelectorAll.bind(document)
Collapse
pavelloz profile image
Paweł Kowalski

Fun fact

If you need to access element via ID, then you can skip functions altogether.

Having element: <div id="my-element"></div> you can access it via window["my-element"] ;-)

Collapse
karataev profile image
Eugene Karataev

It's not always safe to use this trick to query an element. For example, if you have <div id="alert" /> on a page, accessing window['alert'] will not return the element you're looking for.

Collapse
jackharner profile image
Jack Harner 🚀

That is a fun little fact.

Good to know!

Collapse
dwilmer profile image
Daan Wilmer

I think your first reason is the main cause of that eighty-something percentage of websites. There is a huge number of websites based on wordpress, and they all have jQuery.

I personally write a mix of vanilla JS and jQuery when writing javascript in wordpress. In most cases I prefer vanilla JS, but sometimes jQuery just has features ready that I need and... it's just there, you know?

Collapse
amandaiaria profile image
Amanda Iaria

The past 6 months I've been not been using it when I'm not coding in a framework. A lot of things that I thought would be easier aren't that bad in es6.

Though $(selector) will always be nice ... I really don't like the document.querySelectorAll(blah).forEach((eachselector) = { so much for something small });

blah

Collapse
pavelloz profile image
Paweł Kowalski

This is how my utility looks like for that:

const $ = (s, p = document) => {
  if(/object HTML.*Element/.test(s.toString())) {
    throw new Error('[utils/dom/$] Passed dom element instead of selector (string).');
  }

  return Array.from(p.querySelectorAll(s))
};

export default $;

I even export it as $ because i got so used to it ;-)))

I should note that it always returns an array, so no matter if it returns one element or multiple, you can still have one code to iterate matching elements. And if you need only one because you know there will be only one, [0] saves the day, just like in jquery unwrapping method.

Collapse
maxxheth profile image
Maximillian Heth

That's pretty nifty!

I made a slight adjustment that will save you the trouble of having to add [0] to the array if there's really only one instance of that selector.


const $ = (selector, context = document) => {

  if(/object HTML.*Element/.test(selector.toString())) {

    throw new Error('[utils/dom/$] Passed dom element instead of selector (string).');

  }

  if (context.querySelectorAll(selector).length > 0) {

    return [...context.querySelectorAll(selector)];

  } else {

    return context.querySelector(selector);

  }

};

Thread Thread
pavelloz profile image
Paweł Kowalski

I had it in previous version, but i value having returned array much more than this. Because i often map, i can safely map over array of one element, but it would throw if i dont have it inside the array. Im huge advocate of that.

Collapse
merlijnvl profile image
merlijn van lent

To be honest, I have no idea if this is an good idea but...

window.$$ = (selector) => {return document.querySelectorAll(selector);};

Does save a lot of keystrokes on an daily basis and because of the double $ most people would at least think of jQuery and thus that it is some sort of selector.

Collapse
aimerib profile image
Aimeri Baddouh

I saw a talk by Wes Bos at JAMstack conf where he did exactly this. Actually he implemented $ for querySelector and $$ for querySelectorAll

I think this is a pretty neat trick, but there's a part of me that always wants to pause and analyze whether it is strictly necessary to expand on the window object needlessly. Do you have any opinions on setting this as a part of the window object vs using a separate function to do this?

Collapse
daniel15 profile image
Daniel Lo Nigro

You can always just make your own function called $ :)

Collapse
ryansmith profile image
Ryan Smith

I use it on a legacy client application. It still works and there isn't a huge benefit from trying to replace it. There are much bigger issues to address with the application before trying to replace jQuery. I try to promote using plain JavaScript on newer development in the project but some developers are more familiar with jQuery, which is okay. Even though JavaScript has caught up to jQuery, I still think jQuery's syntax and functions are more convenient to use.

Collapse
emh333 profile image
Ethan Hampton

Precisely my situation. There are many, many other things I would want to improve in the application I am working on before I even think about touching something that although old, still works just fine

Collapse
afewminutesofcode profile image
Aaron

Im glad you are taking this practical approach. I think you should always prioritise improving the product functionality for the user over refactoring the code for the sake of it. Keep up the good work

Collapse
anuraghazra profile image
Anurag Hazra

Please also add #jokes tag

Collapse
skydevht profile image
Holy-Elie Scaïde

Not regularly, but I have use jQuery. Mainly where I have a simple web app (A few pages without much logic in them, just showing some content). Going with React would be too much a hassle (You have to maintain consistency within the global state). And the few times I had to work on a Wordpress site (I guess they are why jQuery still have this usage)

Collapse
adebai profile image
Adebowale Ayodeji

When people see some set of new tools, they always forget the good part of the former, and will be blindfolded on the bad part of the later.
As for me, even though I'll ditch jQuery for vue on big projects, jQuery is still ok for some reasons.

  1. Supporting IE, the default browser of windows 7 is very important.
  2. When you use a cdn, the 30kb pain is gone.
  3. It's very cool to replace selectors, but when you try replacing the $.ajax, $('#id').show(), .animate, etc with plain JS, you're really stressing yourself just because "You don't wanna use jQuery"!
  4. Even without any JS knowledge, you can still edit jQuery code (I know what I'm saying!), and approximately every web developer understands jQuery. jQuery's age or modern JS should not judge whether you need a framework/library or not, your project should be the judge! I only wish folks from envato and the likes are here...
Collapse
sroehrl profile image
neoan

I am currently working on a project that uses jQuery. And honestly, even though I thought I remembered the pain points, it is way worse than I recalled.

I guess we all have to thank jQuery for paving the way in so many ways. But at the same time: please stop using it! It hurts. It invites writing terrible code while providing nearly no more advantage over plain ECMA.

Collapse
iamschulz profile image
I am Schulz

I refactored a jQuery project to vanilla a few weeks ago.
Working with e-Commerce software has you using jQuery frequently as well. The ecosystems of Magento and Shopware for example have deep roots in jQuery.

Also, there's still a reason for jQuery. Sometimes, it fits just right into a project. Especially medium sized projects that are not expected to grow a lot could benefit from a smaller bundle size compared to what babel and webpack wrap up sometimes.


Also, what even is a legacy codebase? Lots of small business pages are made well before 2015, when es6 was finalized. For most pages it's just not feasible to adapt a new codebase every 5 years, hence Bruce's "shocking" statistics. I wouldn't call jQuery based projects "legacy" for the sake of jQuery.

Collapse
sroehrl profile image
neoan

Uff. This would be a lengthy discussion as you can of course write nicely. The emphasis was in "invites [... writing terrible code]".

On a high level, DOM interactions are normally done by directly using the selector, usually wrapping the same elements over and over again.

$("#btn").click(function (){

    $("#btn").html("resend");
    // Or
    $(this).html("resend");

});

Both of these common options are strange as in the first version we create a new instance while the second one takes the this object which does not inherit the jQuery prototypes and therefore needs to be wrapped into a jQuery element again. This is especially weird considering that most listeners are shorthands for .on(event, function(event){}), which would hand you the native source element.

The usual result is either assigning many variables globally or repeating selectors until the doctors come.

Collapse
arschles profile image
Aaron Schlesinger

Hot takes incoming!

A ton of sites I've worked on don't really need a larger framework, but I keep noticing that it's dangerously easy to convince myself that I need React, Vue or something similar.

If you're building Spotify, you need a framework. I get that because it's truly an app. But take Facebook or Twitter. Those feel like websites that don't need a framework. That being said, I use Twitter every day, so I'm not complaining or criticizing.

Now that my hot takes are over, I keep some rules in mind when I build a site with jQuery. Some of these I learned from using StimulusJS, which ironically enough is another framework!

  • Try to store state in the DOM itself, right next to the elements that need it. Use data-* attributes for this
  • Try not to use object-oriented design patterns. Keep the code as functional as possible
  • Use typescript when I can
Collapse
mjsarfatti profile image
Manuele J Sarfatti

I use React whenever I can, but at times it just makes no sense.
I tried to insist on going jQuery free/vanillaJS on a recent project but my team rebelled against me 😅

And to be honest I couldn't defend my position that much. jQuery makes writing small interactive features sooooo much faster than vanilla. Fact.

Anyway, I recently found out you can actually have multiple React roots, so next time I have to work on a regular website I'm going to go that way (as opposed to jquery-pluginify all the things).

--EDIT--

At a point I even built my own blazing-fast DOM abstraction/selector: github.com/mjsarfatti/dusk – but never really used it much.

Collapse
ahferroin7 profile image
Austin S. Hemmelgarn

Bit of perspective here, but Bootstrap (still very widely used) still depends on jQuery, and there are a number of jQuery plugins that are exceedingly popular (select2 comes to mind immediately).

I'd be willing to bet that a vast majority of jQuery use is either to use stuff that depends on it like that, or are sites that don't have the practical ability to update to something newer.

Collapse
pavelloz profile image
Paweł Kowalski

I highly recommend looking for vanilla alternatives - given example (select) i have found two worth checking out: Choices, Selectr.

Collapse
ahferroin7 profile image
Austin S. Hemmelgarn

Agreed.

The problem is that a lot of people just stick with what they already know and don't look beyond that (and honestly, in the specific case of select2, I can kind of see why, I've yet to see a vanilla alternative that provides all the same features and doesn't bring it's own set of potentially significant complications).

Of course, really popular platforms like WordPress including jQuery isn't helping either...

Collapse
daviddalbusco profile image
David Dal Busco

I recently spent three months on a client's Java project for which I had to use jQuery.

  1. The UI was developed with JSF respectively Primefaces which (still) relies on jQuery
  2. IE still had to be 100% supported without Polyfill

I've to say, after a bit it was actually fun to develop and furthermore inspired me my last ideas of blog posts 😉

Collapse
pavelloz profile image
Paweł Kowalski

Some might argue that jQuery is polyfill (IMO biggest pro of jQuery is that it polyfills/unifies/abstracts ugly APIs under its umbrella), when it comes to a lot of browser differences (especially old ie).

Collapse
daviddalbusco profile image
David Dal Busco

You know what, I actually never thought about it that way but that's actually a really clever and simple way of describing jQuery nowadays.

Thank you 👍

Collapse
jcubic profile image
Jakub T. Jankiewicz

I would just add that MediaWiki, which is used by probably the biggest website on Internet the Wikipedia, use jQuery as main JS frameowork. And I don't think it will change. I don't see any reason why you would like to rewrite to something new just because it's invented. jQuery works just fine and it's easy to learn and use.

Collapse
bobbbay profile image
Bobbbay

No joke, I use JQuery a lot - it really helps me every day. Truth told, though, I personally think the whole thing will be deprecated next year. JQuery is great, but I think it's going to go away soon as JS advances so much that the uses for JQuery lessen and lessen.

Don't get me wrong - JQuery is absolutely amazing, and I'm not surprised 85% of people use it, but JS is evolving so fast that there might be no use for it anymore.

I have lately found that for everything I do in JQuery, I could do in JS (give it take). Why load a whole library for nothing?

JQuery is legacy, but all legacies come to an end... 👋👋 JQuery 😭😭...

Collapse
dennisk profile image
Dennis Keirsgieter

I have to use it.. We are in the middle of re-building our product using vue.js (nuxt) and graphql. But all our current clients still run on websites using jQuery so whenever they need support or new functions.. it's jQuery time :(

Collapse
pavelloz profile image
Paweł Kowalski

Most of the projects i migrated from jQuery to vanilla, was done exactly by having jQuery project and writing new code in vanilla. Sooner or later dependency will not be needed. ;)

Collapse
kevin_j_morse profile image
Kevin Morse

I'm actively using it for a number of reasons. I have been selling/maintaining a SAAS application for a very niche market for the past decade. jQuery works, is actively maintained, and I know how to use it.

Occasionally when completely refactoring a section I try to write vanilla JS but most of the application is jQuery. My customers don't know the difference so trying to strip out jQuery in order to replace it with whatever happens to be the newest and most shiny really makes zero business sense.

Collapse
wps13 profile image
Willane Paiva

I use it on daily basis, cause of my current job.

Collapse
tariqabughofa profile image
Tariq Abughofa

Do I use it in my projects? most of the time. Do I actually use it? never. It's just there for bootstrap...

There was a time where it had its purpose. I don't think that applies anymore. It just pollutes the code when you use a frontend framework.

Collapse
dpashutskii profile image
Dmitrii Pashutskii

When jQuery deep inside the project, you're not going to get rid of it, you just try to write a new code without, but it's still there.
I think this numbers is the same as WordPress Internet will be there for a long time.

Collapse
cjbrooks12 profile image
Casey Brooks

I've been using it up until very recently (the last few months), when I've discovered Kotlin/JS to actually work well enough for my needs. Now, I use the vanilla JS APIs directly from Kotlin, and have finally kissed JQuery goodbye!

Collapse
patrickb profile image
Patrick Bradshaw

I work for a tiny software company (my very first dev job) and we use a ton of JQuery and Asp.NET WebForms.

JQuery helped me become comfortable with reading and writing a lot of JavaScript, but after becoming familiar with newer frameworks like Vue and React, JQuery started to feel real clunky.

Collapse
brunooliveira profile image
Bruno Oliveira

As some of you might have read, I've used quite a lot to support some of the features in my Flask application, which is being developed with pure JavaScript, and Flask HTML templates. I have never used any front-end framework apart from Angular 1, and, I have to admit, for the size and scope of my side projects, I love the convenience and power of what jQuery allows me to do, especially regarding making my app feel more sleek and interactive.
I don't work with either jquery or anything at all front-end related at my daily job, so can't comment much more.

Collapse
daneren2005 profile image
Scott

I work side by side of projects that are based in jQuery and Vue. I have honestly been considering going back to using jQuery because the selector syntax is so much nicer and I am more used to using $.ajax vs axios or fetch. As a full framework it is past it's prime but it still has some nice utils I like to use.

Collapse
jsn1nj4 profile image
JSn1nj4‍‍👨‍💻

WordPress comes with it and much of the WordPress ecosystem relies on it, so there's that. 🤷‍♂️

I also sometimes look for small JS plugins I can make use of quickly for a carousel (e.g. Slick) or some other interactivity on a simple HTML site/page. Usually there's a jQuery plugin for it.

Collapse
nektro profile image
Meghan (she/her)

I do. I think JS frameworks are the main source of modern bloat and still make my sites fairly hand-crafted. And modern stuff that isn't React/Vue/Angular still use it. I feel calling it "medieval" is very inaccurate.

Collapse
leob profile image
leob

I sure do, when I'm not building a 'SPA' ... in fact it's a very well designed library, simple and it just works - when you maintain a little bit of discipline in order to not make it a mess, that is.

A drawback that I don't hear mentioned often is its bundle size - it's surprisingly big considering what it does (I saw that for the next release they're planning to make it smaller). Also it's not really using ES6 as far as I know. And TBH most of what jQuery does can quite easily be done with the native DOM api (and 'fetch' for AJAX).

For my current Laravel project I am considering to replace it with StimulusJS (of Rails fame). However to then completely phase out jQuery I'd also need a solution for Bootstrap which currently has a dependency on jQuery (for Bootstrap 5 they're planning to remove jQuery as a dependency).

But, to make a long story short, yes I've used it on a bunch of projects and am not ashamed to admit it :-)

Collapse
not_jffrydsr profile image
@nobody

I remember reading jQuery documentation in 2015 while learning Java Swing and thought 'I'll take this whole web app thing when they've agreed on a syntax'. . . years later that's now the medieval period.

Collapse
aligoren profile image
Ali GOREN

You shouldn't define yourself with a technology or a library or a framework. Actually, jQuery helped developers in a lot of projects.

These are great plugins for jQuery;

jQuery DataTable, FullCalendar, Carousel, tooltipsy, etc.

It still using by WordPress so we can't say it's legacy.

Collapse
doug profile image
Doug

I originally used it to solve browser compatibility, and it also helped make the language easier to read (for me!).

Fast forward 10 years, the C# MVC project I was working on is heavily split between backend (API) and frontend (Javascript). Sticking to what I know, there is heavy use of jQuery (also to replace a commercial control library). Eventually I realise this is beyond what it was made for and I'm re-inventing wheels or looking for plugins to help.

These days I get to use Angular, which has it's faults, but I refuse to drop back to the comfortable arms of jQuery, because I'm not having the problems it was originally solving for me.

I have trememndous respect for jQuery, but my coding style and needs have moved on.

Collapse
jacobherrington profile image
Jacob Herrington (he/him)

I only use jQuery.

Collapse
katnel20 profile image
Katie Nelson

This codebase that I was asked to make changes to uses jQuery. It wasn't so difficult to pick up, but I understand how it would be hard to replace without a total rewrite.

Collapse
david_ojeda profile image
David Ojeda

I use it mainly when maintaining current features on our app; most of the client-side behavior is jQuery. All new features I develop are using vanilla JS together with Stimulus.js.

Collapse
nedyudombat profile image
Nedy Udombat

Bootstrap won't let me shine(Just kidding).
I use it when I want to work with a Ruby application and I am implementing my FE with CoffeeScript, I add Jquery to the mix.

Collapse
zeslova profile image
Simon Newby

L*gacy code

Collapse
enmel profile image
Enmanuel Marval

I do not!!! Huahaha

But some of my coworkers are still clinging to him. A couple have followed my example and have begun to leave it gradually. It is a total success!

Collapse
sizemj profile image
Jason S.

I still use it for SharePoint 2013 work that still needs to support IE 11.

Collapse
sandwich_hlp profile image
Michael Cohen

I use it for cross-browser compatibility, and because it has good documentation, which regular JS—as far as I can tell—does not.

Collapse
rose profile image
Rose

Legacy :) the app I work on is 10 years old and there are some older parts that are pretty tightly coupled with jQuery.

Collapse
rootsmj profile image
Martin Johansson

Only in projects older than 4 years that I'm still maintaining. Otherwise, no.

Collapse
vladimir_dev profile image
vladimir.dev

🙋‍♂️ Here!

Reason? Just inheriting and maintaining old projects.

Collapse
michaeldemutis profile image
Michael DeMutis

Ain't this some nonsense. Maybe the better question would be who no longer uses jQuery.

Collapse
azhsetiawan profile image
Ashar Setiawan

I'm still using JQuery in WordPress theme and simple static site.

Collapse
msamgan profile image
Mohammed Samgan Khan

me me me.......