4 ms·
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 compleme
by mike_d 5y ago
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.
- dotancohen 5y ago> 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.
- themodelplumber 5y agoI 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-jquery-alternatives-2019.html https://www.technotification.com/2019/06/5-lightweight-jquer...
- azophy_2 5y agovanilla javascript has improved a lot these years. however I've found that alpinejs is small & nice if you need better syntax for interactivity
- andrei_says_ 5y agoStimulusjs, alpinejs.
- girvo 5y agohttps://htmx.org/ 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/ 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/ https://alpinejs.dev/ I love both of these libraries.
- egeozcan 5y agoI 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/cdc90e290271f3ea4b6801dcf1aad719 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.
- dsego 5y agoFor 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.
- chrisweekly 5y agoIE is dead.
- dsego 5y agoYup, and frankly I don't understand why the commenter think they need an xhr wrapper nowadays ¯\_(ツ)_/¯