Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I could see this being extremely useful for weekend projects where you just need to build a UI for something.

Any recommendation for a lightweight and complementary JavaScript library? Validate forms, XHR wrapper, etc. without the bulk of jQuery.



https://htmx.org/

That does 90% of what I need when sprinkling backend AJAX-y interactivity on a straight HTML page with a backend that sends JSON or HTML back.

https://htmx.org/examples/inline-validation/

For more jquery-esque fine-grained control for building custom elements/components on my pages I turn to:

https://alpinejs.dev/

I love both of these libraries.


I also love Alpine.js, but after implementing a dropdown with it, I'm thinking maybe sometimes it's too verbose especially combined with tailwind.

https://gist.github.com/egeozcan/cdc90e290271f3ea4b6801dcf1a...

I should mention, I did want it to be quick and dirty (it's a prototype), but well, it could have been a bit more concise. Double set parentheses come from the templating system I use BTW, if it wasn't clear.

Being HTML oriented is very cool, and you get a lot of things for free, but I keep saying "oh this would have been much easier with react" a bit too much.


  > Any recommendation for a lightweight and complementary JavaScript library?
  > Validate forms, XHR wrapper, etc. without the bulk of jQuery.
Today, targeting modern web browsers? Vanilla Javascript, really.

Since ES6 (2015) Vanilla Javascript has been very good. Form validation is free with HTML5, XHR is already wrapped with a one-line Promise API.


I used Zepto once for a weekend project without jQuery and it did what I needed very well. Though these days I would also check in with e.g. plain JS (way better support than when jQuery started) and projects like htmx at the other end of the "well but I need an app, but want to go light" direction.

Seems there are some more ideas here: https://www.technotification.com/2019/06/5-lightweight-jquer...


For xhr you can use native fetch afaik, the only browser that doesn't have it is good old IE. Basic form validation is baked into html forms. And most of jquery selector stuff is easy to do in vanilla JS.


IE is dead.


Yup, and frankly I don't understand why the commenter think they need an xhr wrapper nowadays ¯\_(ツ)_/¯


Stimulusjs, alpinejs.


vanilla javascript has improved a lot these years. however I've found that alpinejs is small & nice if you need better syntax for interactivity




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: