6 ms·
I'm finding I don't need jQuery anymore. What are the reasons people still use it?
by mozumder 10y ago
I'm finding I don't need jQuery anymore. What are the reasons people still use it?
- mindcrime 10y agoI use it for a couple of (related) reasons. 1. A few other libraries still depend on jQuery in turn, so I find that I still usually have it available in every app I work on anyway, so I might as well use it. 2. It "just works" and I already know it, and since it's already there, anyway (see (1) above) it just makes sense to use it. IOW, I don't feel enough pain from using jQuery to justify going off and learning what combination of new ecmascript (es6? es7? es9037253223252??? ???) features and/or libraries du jour that I would need to do everything jQuery does for me now. That said, I mostly just use it for the selectors - which I understand can be easily replaced with native features now - and the ajax method. So in reality, yeah, I probably could ditch jQuery without too much pain, excepting for (1) above, but... why bother? I don't care too much about the size, since I don't typically link in tons of javascript libraries, ad networks, etc. to kill page load times, and page bloat seems to be the biggest argument I hear against using jQuery.
- mozumder 10y agoAnd, why should a new developer on fresh projects use it? It seems ES6 and latest CSS specs should cover everything JQuery used to be used for. Plus, wouldn't actually using Vanilla JS be faster? Right now it looks like people use JQuery for legacy code. But, they give no reason to use it for new projects, except if they need it for other libraries they're going to use. (based on legacy code anyways...) JQuery looks redundant in the modern Javascript era on evergreen browsers.
- jackmoore 10y agojQuery is still much more pleasant to use than native methods when working with collections of DOM elements. If you do much DOM manipulation, you'll end up writing helpers that replicate aspects of jQuery to grease your workflow. The real issue is that trying to manage state by directly manipulating the DOM becomes a nightmare as the project grows, and newer frameworks can mostly take care of that for you. So jQuery is still wonderful at what it does, but there isn't much reason to be directly manipulating the DOM now that there are alternatives.
- rpwverheij 10y agoagreed, if you want to keep things simple jQuery is still a nice tool and ES6 only makes it nicer to type, ES6 does not improve native DOM manipulation
- georgestephanis 10y agojQuery also tends to handle a lot of assorted browser quirks, giving you a consistent api to call.
- unclebucknasty 10y agoYeah, initially they was one of its biggest selling points.
- snaky 10y agoAnd now it isn't?
- unclebucknasty 10y agoRead the ancestor comments.
- DCoder 10y agoIn addition to handling well-known browser inconsistencies, it also covers obscure edge cases such as these: https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0RlhdnPx_ePXm7oW02iiT6o/edit https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0Rlh...
- deckiedan 10y agoFor quick mock up / temporary pages sometimes regular JS is quite verbose, and a full framework or whatever like react/mithril/angular/ember/whatever is too much extra hassle. When writing 20 lines + 2 plugins in jQuery is enough to make a 'static site' feel much more interactive / responsive (UI, not screensize) then sometimes it works great. It's a bit like the perl of web page JS for me. I wouldn't recommend writing a full complex application in it - although that is possible and by people who know what they're doing can be done cleanly and organised... but for super quick hackery, it's hard to beat.
- snomad 10y agoRequired component for Bootstrap and Foundation.
- badthingfactory 10y agoOur company still uses it a bunch. Higher powers enjoy the "benefits" of using bootstrap themes which are bundled with a mess of random jquery plugins from around the internet. Our dev team has actually been quite successful at wrapping many of these plugins into react components to abstract away plugin details.
- exodust 10y agoI'm surprised you're asking for "reasons people still use it" when that is already quite obvious. How about telling us why you don't need the most popular JS library?