4 ms·
Ask HN: I'm curious to know why should we use jQuery now?
- legrande 3y agoI use it purely for the syntactic sugar. It's less characters to type than vanilla JS[0]. I've toyed with Cash[1] too which I use for small projects that don't need the entire jQuery lib. [0] https://youmightnotneedjquery.com/ https://youmightnotneedjquery.com/ [1] https://kenwheeler.github.io/cash/ https://kenwheeler.github.io/cash/
- bapetel 3y agoHmmmm Nice resources, thanks
- deleted 3y ago[deleted]
- gregjor 3y agoMainly because so much jQuery already out there. For a fresh project it's harder to make an argument for it, but if you work with legacy code you probably have to know jQuery. Personally I like jQuery. Like so many developers I started using it a long time ago because it solved numerous browser inconsistencies and incompatibilities. Then I got used to the clean and concise syntax. Now I use htmx more than jQuery.
- bapetel 3y agoFor fresh project, maybe it's better to use a modern tool
- gregjor 3y agojQuery 4.0 is out in beta, so I think it qualifies as "modern" in the sense that it still has active work and progress. It's not "new" if that's what you mean. I would prefer the well-understood and tested in the real world tool over something new and shiny. You may not need jQuery because vanilla JS can do the same things now. Or you may have other tools that do what you need. But choosing something because it's new or supposedly "modern" only makes sense if the alternatives are obsolete or prevent you from doing something, and jQuery isn't either.
- valrix 3y agoYou probably should not use jQuery unless you have an actual need for it. 10-ish years ago it was helpful because browser features were very fragmented at the time and it was hard to write code that would correctly function across all major browsers. Today, there's little difference (mostly due to them all being the same under-the-hood nowadays) so instead of being a helpful tool, it's being overused for numerous reasons. Most of what jQuery was really good at has now been added to Javascript core or there is a browser API for it.
- bapetel 3y agoBut if I work on legacy projects, I have to know JQuery
- ale_jacques 3y agoI'm using Unpoly (https://unpoly.com https://unpoly.com) instead of htmx. One thing that, sometimes, makes me consider pairing it with jQuery are the components built around it. Stuff like datepickers, autocompletes and whatnot are very consolidated in jQuery world. Sure there are options for vanilla JS but they are not mantained or do not have all the features. These components are being built for the Reacts and Vues frameworks these days.
- bapetel 3y agoYep, plugins in JQuery world are really consolidated and mature