16 ms·
Do people still use jQuery? I thought the biggest advantage of this library back in the day was css selector access of DOM nodes (back when we only had getElem
by cphoover 6y ago
Do people still use jQuery?
I thought the biggest advantage of this library back in the day was css selector access of DOM nodes (back when we only had getElementById, getElementsByClassName, and getElementsByTagName). This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll.
Also there are browser compatibility issues that jQuery solved but a lot of these are solved with smaller footprint libraries like lodash.
Also for me, along with I'm sure many others, keeping state within the DOM has fallen out of favor of more comprehensible state management inside of JS (like React Hooks, Redux...etc.)
What is the current use-case for jQuery? I'm curious from hearing it's current users answer this.
- k__ 6y agoLegacy systems, probably. I read, Ember.js would depend on it.
- m00dy 6y agoI use it for my landing page in countingcarbons.co
- duxup 6y agoEvery day I do. Granted I don't so much as use it as I fix it / change it. Anything new is just vanilla as far as the legacy systems go. But those legacy systems pay the bills...
- muglug 6y agoI think a lot! For example, the new https://www.whitehouse.gov https://www.whitehouse.gov uses jQuery. When you just want to add a small bit of interaction to a mostly-static site, jQuery can help. There's a current trend to complicate things with a JAM stack that really don't need to be complicated. I've seen people propose something like [NodeJS/Ruby/PHP backend] -> GraphQL API -> React Frontend -> static html Where really they could have just gone with [NodeJS/Ruby/PHP backend] -> static html
- kyriakos 6y agoTo be fair the first case is only static for the initial load then becomes a single page application
- muglug 6y agoYeah, but very few sites need to be SPAs. SPAs come with a tremendous amount of extra requirements that, over time, can mire projects in cruft.
- wishinghand 6y ago> When you just want to add a small bit of interaction to a mostly-static site Then I'd reach for Alpine. Very lightweight, and I can use the fetch API instead of $.ajax.
- makeworld 6y agoPerhaps even htmx? https://htmx.org/ https://htmx.org/
- iagovar 6y agoThis looks very cool, thanks.
- ergo14 6y agoor Lit-Element.
- purple_ferret 6y agoJquery has been around for 14 years. That framework..16 months. You want to be as confident as possible you can bump to a new version on your old site in 4 years if you have to? Use Jquery.
- SamuelAdams 6y agoPlus it's easier to hire for. Chances are more developers have experience with JQuery than <new hot js library>.
- krab 6y agoFor me personally, it's partly familiarity and also still compatibility. I know that if I use jQuery, then (for the parts it covers) I don't have to search caniuse.com. But then, I'm not a front-end web developer, so I optimize for different type of projects.
- HaloZero 6y agoI use it primarily because it provides an easy interface for ancestor, descendant utilities. But I'm also not doing this in a FT setting, just for side projects.
- llarsson 6y agoEvery single WordPress blog ships it by default. I would not start a greenfield project based on it today, sure, but it is used by a truly staggering amount of sites today, so having it get updates in the form of security fixes and some additional functionality benefits a large part of the web.
- bcrosby95 6y ago> This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. Have you actually compared the two methods in a real website? It's like saying why use Ruby when you can use Java. The Javascript document API is super verbose. No thanks.
- frabert 6y agoHow so? Who stops you from doing something like `const $ = document.querySelector`?
- cphoover 6y agoGood point
- Epskampie 6y agoThere's a ton of other functions you need like element.addEventListener, insertAdjacentElement, XMLHttpRequest (when you need progress) etc. etc. At that point you might as well save yourself and the person after you a major headache and just use jQuery whose API everybody knows.
- cortesoft 6y agoThe big magic of jQuery is that you can act on an array of elements as if it were a single element. Your alias does not give you that at all.
- cphoover 6y agoYou don't have to use all of it though, right? You can choose to only only use the applicable parts: eg: ``` $('.container-element') .addClass('active'); // vs document.querySelectorAll('.my-class-selector') .classList.add('active') ``` I use the native APIs all the time, they are not that complicated or overly verbose. Easily memorized with practice IMHO. Also they are all extremely well documented on MDN.
- deleted 6y ago[deleted]
- laurent92 6y agoI never understood why people say “We’ve solved your jQuery problem” by introducing getElementsByClassName() or even querySelector(). When I come back to my older app, $(“.my-class”) is still much nicer. jQuery gets out of the way, the class gets syntax-highlighted, and .focus() can’t create an NPE.
- wishinghand 6y agoOne could also save document.querySelector to $ as a constant.
- vbezhenar 6y agoThat would be very confusing for unsuspecting reader. Please use something different, I would suggest `qs` for `querySelector` and `qsa` for `querySelectorAll`.
- wishinghand 6y agoThis method is not so much for multi-dev codebases but for single devs working on their personal or low-tech sites and are having a hard time letting the $('some-selector') syntax go.
- tyingq 6y agoI know it doesn't replace jQuery, but this is fairly straightforward: $ = document.querySelector.bind(document) $$ = document.querySelectorAll.bind(document)
- vijaybritto 6y agoUsing this since ages. Also use window.DOM = document
- arp242 6y agoIt's annoying that it returns a NodeList which doesn't have some common array-y methods and the like. While these aliases are certainly convenient, the jQuery semantics are much nicer and more intuitive IMO.
- aakkaarr 6y agoIt is still bundled in WordPress and WP is still most popular CMS (30% sites on the web runs on it) It is not necessary to use jQuery when you build site but tons of tutorials on the web is using it so people does. Plus wp-admin still loads jQuery for itself so it is in use even unnoticed.
- abhisuri97 6y agoYep. I still use it for side one-off projects here and there. For me, there's just something so convenient about being able to make a html page that you can drop in a quick CDN link for jquery and not have to worry about compiling, webpack, create-react-app etc. I'll still use React when something is a larger project with a ton of moving parts, but otherwise I stick with jquery. As for why I'm not using the native DOM api's...I could, but haven't gotten around to learning that syntax since I'm very used to jquery (being specific, if I want to do things that are more complicated than selecting an element + changing its properties, the native API is more complicated). jquery is just a nice default.
- cphoover 6y agoI hear you. Personally I think learning the native APIs isn't so bad once you take the plunge. They are easily memorized with practice. Imagine not needing to go for that CDN link (or depending on some 3p for your website to work correctly)
- megous 6y agoIt's not that more complicated. There are after()/before()/closest()/remove(), and a lot of other similar easy to use methods these days. It's not el.parentNode.insertBefore(new, el) and el.parentNode.removeChild(el) days anymore.
- spiderfarmer 6y agoDaily.
- tenryuu 6y agoI dropped it a long time ago for similar reasons to only using selectors. It was not worth adding the extra request and execution time for what was really now a vanilla feature.
- dr-detroit 6y agoany popular library is already cached in everyone's browser and therefore *ANNIHILATES* the performance of every character of .js code you've ever written including inline
- RHSeeger 6y agoIt is literally the first thing I add to every personal project I build, and it's included with a lot of things I work with professionally. Jquery just makes life easier.
- lostgame 6y agoThis. I can just prototype something so gosh darn quickly in jQuery and I'm so used to it by this point that between that and advancements in CSS it's incredibly awesome. Why replace what's not broken?
- tyingq 6y ago"What is the current use-case for jQuery? I'm curious from hearing it's current users answer this." I still see it used for file upload/download, as the fetch api doesn't provide a reasonable way to show progress if the channel is using gzip or deflate. The ajax functionality is also still popular for a compact way to deal with different types of errors (app errors vs connectivity errors).
- kemiller2002 6y agoThere are still a ton of legacy sites that use it. New development? Don't know, but the last 2 companies I worked for had massive systems written in JQuery.
- justsomeuser 6y agoI like jQuery because: - The API is still more concise than what is built into the browser (Compare the number of lines used here: http://youmightnotneedjquery.com/ http://youmightnotneedjquery.com/) - It is still useful for older browsers that might not support something. - The API is burned into my brain, it speaks jQuery. - If I have any issues, Google will usually surface how to use the API faster than the (standards compliant API * can I use it?) I do use React for UI, but sometimes you have to interact with the DOM; in those cases for larger programs I find jQuery easier to read and write.
- manishsharan 6y agoI use it extensively to maintaining our apps ui which has coded with old fashioned Backbone, Underscore and Jquery. our UI is working and we do not see need to re-engineer/refactor it to go to newer frameworks just for the sake of it.
- brunojppb 6y agoYou wouldn’t believe in the amount of solid applications using jQuery out there. It’s still widely adopted, specially when you are maintaining legacy applications. While I personally don’t use it in my day job anymore (Mostly React nowadays), I still know a good number of people that use jQuery in my local community. Worth noting: Legacy doesn’t mean bad. Just software that sustained the tough test of time.
- mortenjorck 6y agojQuery is like WordPress. There may be other more streamlined, purpose-built solutions out there, and they all have their uses, but sometimes ease of setup is the thing you're optimizing for, sexiness be damned. When you have a vast, mature ecosystem and a decade and a half of community knowledge to draw upon, even the most obscure use cases tend to have a precedent somewhere. Being able to jump right to a StackOverflow answer to exactly what you're trying to do is, in my opinion, a highly underrated feature of legacy web technology.
- andrei_says_ 6y agoI’ve seen the code of Wordpress and would not touch the spaghetti cluster-f that it is. I won’t even speak of the ecosystem built on the above principles. All I can say is that a 1-click install does translate to popularity :)
- mschuetz 6y agoI'm trying to wean off of jQuery to reduce dependencies, but it makes me appreciate jQuery all the more. The native JS API is quite a bit more verbose and cumbersome to use, and my absolute biggest gripe with it is that it doesn't even build on modern JS features. It's not compatible with for...of, map, filter, find, etc, which seems really strange for a relatively recent vanilla JS API. Ironically, http://youmightnotneedjquery.com/ http://youmightnotneedjquery.com/ makes a pretty good case in favour of jQuery.
- megous 6y agoYou can easily extend NodeList.prototype with Array.prototype functions you like, and then just use them: ['map', 'find'].forEach(f => NodeList.prototype[f] = Array.prototype[f]); document.querySelectorAll('bla').map(el => whatever) That's what prototypes are for, anyway.
- rofrol 6y agoNice, ['map', 'find', 'filter', 'reduce'].forEach(f => NodeList.prototype[f] = Array.prototype[f]) // this is for for..of, cannot be above 'map', 'filter' etc. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator] document.querySelectorAll('span').map(el => console.log(el)) document.querySelectorAll('span').filter(el => el.className === 'fc-black-500').reduce((acc, el) => (acc += el.className, acc), '') for(let p of document.querySelectorAll('p')) { console.log(p) } - https://stackoverflow.com/questions/30836289/for-of-loop-queryselectorall https://stackoverflow.com/questions/30836289/for-of-loop-que...
- megous 6y agoYou can also create a getter on NodeList.prototype named '_' that returns Array.from(this) and then just use any of the array methods on it. Like document.querySelectorAll('div')._.some(...) So many options. :)
- bigfudge 6y agoWhat I don't understand is why the modern js api didn't just adopt query's conventions... they're so much nicer and more expressive most of the time.
- tambourine_man 6y ago>Do people still use jQuery? Oh yes. Everyday. Still love it. >…Javascript document api via document.querySelector, and document.querySelectorAll The jQuery API is still (and probably aways will be) far superior to the native DOM (terser, composable, more expressive, etc). >…smaller footprint libraries like lodash jQuery is ≈30k gziped and most likely already cached from CDN. >…has fallen out of favor of more comprehensible state management inside of JS (like React Hooks, Redux...etc.) Managing state is hard. There shouldn't be much of it in any single view. IMO, React doesn't bring much to the table in this regard while adding a lot of complexity and heft. Vue is a bit better, but still, I'd much rather use jQuery if given the choice. If you're building something like Spotify/Slack, I can maybe see the need for virtual DOMs, etc. If you're sprinkling interactivity to your webpage, which is arguably what most of the web should be, jQuery is probably as good as it will ever get.
- actuator 6y ago> IMO, React doesn't bring much to the table in this regard while adding a lot of complexity and heft. Strongly disagree with this. In any complex web application with a lot of components, specially ones where a lot of fixed components can live for a while, React is definitely a massive improvement over vanilla JS or something like Backbone which allows wild west. Imagine state coming from sockets, rest APIs etc with updates being either pull or push. A user might do an action which changes the state in some other component, keeping track of the components gets hard if the state is distributed. Also, centrally managed state with things like Redux allows for good caching of API data which can make a SPA considerably fast. While I love plain HTML pages which need little or no JS, a lot of applications are better as SPAs.
- gorgoiler 6y agoI think it’s like Lisp, or rather the reaction to Lisp. In a world without jQuery every site / devshop uses their own little set of conventions and polyfills (analogous to macros) to add useful abstractions. In isolation, these are neat. En masse though it means that each site has their own meta language (conventions) which have to be memorized before you can contribute to the code base. Languages like Ruby and Lisp suffer from this too: there are so many minute variants across code based that it becomes hard to truly view them as the same language. jQuery, in the context of JavaScript, is a standardisation track for all those little language additions. Personally, I just use the native APIs. I don’t work with enough people across enough sites to benefit from standardisation. You will probably find a big overlap between proponents of jQuery and professionals — especially contractors — who work with many other people on many different codebases.
- bigfudge 6y agoOr just people who have a poor memory, or who are not very self consistent. I love things like jquery (and Django and other opinionated frameworks) because it saves me the hassle of having bike shed trivial details for myself and then remember them later. And naming things is one of the two hard problems etc...
- blain 6y agoWell, Wordpress and Drupal still uses jQuery, they auto load it by default and there is no reason not use at this point, unless you specifically building React or some other custom thing on top of either of them.
- okhan 6y agoI help teach an introductory programming class to high school students. We still use jQuery to teach basic programming concepts, because it helps students add basic interactivity to a web page without a) the overhead of learning a full framework like React, or b) exposing them to the insanity of web APIs. Check out the curriculum if you're interested: https://github.com/itscodenation/curriculum-20-21 https://github.com/itscodenation/curriculum-20-21 If you just want to add simple interactivity to a web page, jQuery provides a really nice API to do just that. Sure it's not the ideal thing to build a whole SPA on, but it has its place.
- stjohnswarts 6y agoI've written a number of small apps for testing at my company with basically jquery+html+rust backend "web server" and it works quite well if you're not trying to get too fancy.
- brundolf 6y agoThere were other things like the "Ajax" (remember that word?) API, but that one's also been matched by a native API (fetch()) > keeping state within the DOM has fallen out of favor of more comprehensible state management inside of JS Not everything needs a whole reactive templating library. There's absolutely still a usecase for mostly-static sites to do imperative DOM manipulation. The usecase for jQuery itself these days is dodgier, since as you point out most of its big features are native now. It should still help with browser compatibility (not necessary for modern-ish browsers, but many sites don't want to limit themselves to modern-ish browsers), its APIs are arguably still a little nicer in some places, and it does have a significant ecosystem of plugins so there's probably some value in having that stuff integrate together. But personally I would have a hard time justifying a whole library just for slightly nicer APIs unless I was doing something significantly complicated, and at that point I would just use React.
- TedShiller 6y ago> Do people still use jQuery? Oh yes. Very much so.
- handzhiev 6y agojQuery is bundled in WordPress and many of the plugins so I guess there are a few sites still using it :)
- rzwitserloot 6y agoStill use it. Still love it. Just last month I decided to toss a quite arbitrary `=>` in my javascript (I still write `function (args) { code }`), and shipped it. Immediately got a _TON_ of user complaints. Turns out, we sent a link in a newsletter, and most folks were reading those in Outlook, and that evidently just opens links internally, and that is still IE11. We don't ordinarily support IE11, but given that this is a specific info page shown there, for this we make an exception, and... => doesn't even work there. Thus, another year goes by, and another year where I am 100% convinced it is totally not worth my time or effort to investigate newer options. I'm honestly confused about why jQuery is considered 'bad'. It's a dependency - yeah, 30k or so. This complaint (that it adds load time) boggles my mind; in this day and age of 10MB+ load pages, and the choice is to complain about a 30k library? Some javascript-library variant of the Total Perspective Vortex may be warranted to try to make sense of this. A more interactive (as in, between server and browser), more stateful integrated model? Oh, yeah, totally, I can see that, but that 'formula' surely isn't the go-to strategy for every web page out there, right? Most of the pages I write work perfectly well via a 'server generates data, server throws it through a template and sends it to browser, client downloads jquery and some javascript for that page which adds interactive elements', and wouldn't be any 'nicer' if it was a much more javascript-native fully state-shared amalgamation. When I do need that live-updating stateful interaction model, sure, don't need jQuery. But that 30k is the least of my worries if that happens.
- shaicoleman 6y ago"Fun" fact: Outlook today still uses Word to render HTML, which is about as capable as IE3 released in 1996.
- colourgarden 6y agoYour use of the word "still" is a little misleading. IE _was_ the default email rendering engine until 2007 when Microsoft made the inexplicable decision to move to Word 2007 instead.
- dragonwriter 6y ago
- terracatta 6y agoI write a lot of B2B apps that have tabular data views. For all of its quirks, DataTables (https://datatables.net https://datatables.net) does a great job and with the right plugins offers all the features my customers expect (re-ordering/resizing columns, column based search, fixed headers, fixed columns, item selection, etc.) DataTables requires jQuery. Lots of other vanilla JS table plugins out there but I can't find one with all of those features that work when they are all on.
- Turing_Machine 6y ago> Do people still use jQuery? All the time. > This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. The official replacements for the stuff jQuery does tend to be verbose and non-orthogonal, as compared to the much more unified and consistent API of jQuery.
- andrei_says_ 6y agoYes, absolutely. The use case: a small CraftCMS-driven site using a bunch of long-lived jquery plugins and almost no custom JS. Also, no need for transpiring or bundling. It is wonderful.
- FpUser 6y ago>"Also for me, along with I'm sure many others, keeping state within the DOM has fallen out of favor of more comprehensible state management inside of JS (like React Hooks, Redux" In my opinion using React / Redux combo for state management is a poor choice. So to each their own. The arguments like: everyone else including my cat does that do not make really it any better in my eyes.
- rburhum 6y agoYes. For quick small things. When I need a to write a small web service, I usually just grab a python micro-framework and do the work. Not much complexity and not a lot of setup required. When I need to do something more elaborate that needs structure because it will get extended over time, I will take my time to setup something like Django... but it would be too much unnecessary work do to that for small web services. The same applies to front-end. When I need a few quick HTML pages that need some quick DOM manipulation, I usually just grab jQuery and do what we have been doing for years. Whenever I know that something will get extended over time and needs structure, that is when I take the time to setup React/Redux and all the build scripts necessary to make it work. Just personal preference, but I am sure I am not alone...
- deleted 6y ago[deleted]
- Havelock 6y agoBrowser compatibility issues can be resolved with Babel and as such fulfills the need of jQuery and allows me to just write javascript.
- AdrianB1 6y agoAjax, foreach, Datatables, small but perfect reasons to use it.
- john-shaffer 6y ago> What is the current use-case for jQuery? WordPress ships with it, so using jQuery often doesn't require any extra footprint. I still prefer vanilla calls for admin-only code, but jQuery has better compatibility for user-facing pages.
- pull_my_finger 6y ago> there are rowser compatibility issues that jQuery solved Current browser support[1] isn't really _that_ great. I know it used to be, but I'm not sure that's a legit selling point these days. Not that it's bad, but I hear that argument come up a lot. [1]: https://jquery.com/browser-support/ https://jquery.com/browser-support/
- racl101 6y ago> Do people still use jQuery? A ton. jQuery is still holding up the client side code of a lot of projects I've worked on and doing a pretty decent job at it. Sure they could be rewritten to not use it but there really hasn't been a business reason to do it. Though I personally wouldn't use it on a new project moving forward that's for sure.
- quickthrower2 6y agoStill use it because the code base is still full of it and don’t want to have multiple patterns. Plus the plugins are really useful and the syntax is nice.
- jacobsenscott 6y agoStill use jquery. Just look at any of the "you don't need jquery" sites to see how verbose even modern JS is for many simple dom manipulation tasks.
- dheera 6y agoI still use it all the time because document.querySelector is nowhere nearly as good as $, and it's extremely verbose to create a nested tree of nodes in vanilla JS. I've really forgetten how to do things without jQuery. If anyone knows a framework that is less verbose than jQuery please tell me!
- jedisct1 6y agoWordpress.
- johnx123-up 6y agoIMHO, if jQuery adds support for the virtual DOM, it will be more attractive
- bobbydreamer 6y agoMakes life lot easy....