DEV Community

Discussion on: Do you still work with jQuery?

Collapse
 
matthewbdaly profile image
Matthew Daly • Edited

Have you looked at Alpine.js at all? I quite like that as a jQuery replacement because:

  • It's tiny - it and Axios together are still only a fraction the size of jQuery
  • It provides a more declarative API, largely copied from Vue

These days I don't really like including jQuery by default on new projects because a lot of it simply isn't needed, but at the same time doing a lot of that stuff in vanilla JS can be a chore. Alpine's so far proven to be a good solution for what I used to fall back to using jQuery for.

Collapse
 
imthedeveloper profile image
ImTheDeveloper

In the same way I'm doing with Vue.js, drop in the script tag and swap out the JQuery. I'll check out Alpine, Vue I just seemed to "get it" quite quick.

Thread Thread
 
tylerlwsmith profile image
Tyler Smith

Alpine has almost everything I like about Vue without the build the steps. It's one of the best front-end tools to come out in the past few years.

Thread Thread
 
imthedeveloper profile image
ImTheDeveloper • Edited

Yep with the cdn script there is no build for Vue either so fully with you on such a low impact way to improve

vuejs.org/v2/guide/installation.ht...

Collapse
 
philw_ profile image
Phil Wolstenholme

+1 for Alpine, I love it when working with server rendered pages.

Collapse
 
tylerlwsmith profile image
Tyler Smith

Alpine is absolutely amazing. It's become my favorite tool for adding interactivity on server-rendered apps that I build with frameworks like Laravel. And Alpine recently added an equivalent of jQuery's slideToggle(), which is the feature I needed most often from jQuery.

I'm not terribly concerned about the extra kilobytes I get from using jQuery. jQuery doesn't block the DOM from rendering, and it doesn't require activation bootstrapping the way that a framework would: it just needs to download and parse. It's very different than React where you can't render anything until the library is downloaded, parsed, and your app code executed. Even server-rendered React has issues with links not working until the app is fully hydrated.

Avoiding extra kilobytes is nice, but it's easy to go down a rabbit hole where we focus on reducing the kilobytes of JavaScript because it's easier to measure than other higher-impact UX like avoiding page jank, creating useful error states, avoiding responsive issues, etc. Alpine feels nicer to use in a lot of cases though!