Settings

Theme

Ask HN: I'm curious to know why should we use jQuery now?

2 points by bapetel 2 years ago · 10 comments


ale_jacques 2 years ago

I'm using Unpoly (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.

valrix 2 years ago

You 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.

legrande 2 years ago

I 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/

[1] https://kenwheeler.github.io/cash/

gregjor 2 years ago

Mainly 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.

  • bapetelOP 2 years ago

    For fresh project, maybe it's better to use a modern tool

    • gregjor 2 years ago

      jQuery 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.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection