3 ms·
> There’s a difference in quality between these jQuery and NPM (and react component) things. Yep, you're exactly right, the plugins are from a different era an
by EB66 7y ago
> There’s a difference in quality between these jQuery and NPM (and react component) things.
Yep, you're exactly right, the plugins are from a different era and have less utility today.
That said, jQuery itself still has immense utility. It's expressiveness and simplicity are second to none.
The author points to youmightnotneedjquery.com as an example of why jQuery is superfluous today, but if you look at the examples a bit more closely, you'll notice problems. I spent all of five minutes glancing through the YMNNJ example list and noticed their `replaceWith` doesn't provide the functionality that jQuery offers -- it doesn't take into account event handlers bound to DOM elements. Also, their `extend` does a shallow merge, not a deep merge. Furthermore, the YMNNJ examples are often much more verbose and less expressive than the jQuery examples.
I don't particularly understand the rush to rip jQuery out of everything. It seems like a lot of people are doing it just because it's the trending thing to do. There are some things that jQuery does very well -- even in today's world where modern web dev is dominated by SPA components.
jQuery and SPAs don't have to be mutually exclusive. At my work, we've been building SPAs with jQuery long before Angular, React or Vue even existed. Within the past few years we built our own JavaScript SPA framework whose components can be written with vanilla JS or jQuery. Most of us prefer to use jQuery for our components because the syntax is often more expressive and concise than vanilla JS. We open sourced the framework at https://github.com/elliotnb/nimbly https://github.com/elliotnb/nimbly and it's state management utility at https://github.com/elliotnb/observable-slim https://github.com/elliotnb/observable-slim
Our framework core uses jQuery to update DOM nodes with `replaceWith`, merge deeply nested objects with `extend`, among other things. Aside from the eliminating the extra 69KB footprint from adding jQuery slim min, we don't see any reason to rush to rip jQuery out of the framework core. On the contrary, using jQuery helped us get the framework built faster and helped us keep the code expressive and easy-to-follow.
Long live jQuery :)
- wolco 7y agoI started a project a few weeks ago and decide to use jQuery because someone on the team didn't know vue and I felt it wasn't worth the effort to convince them to try it. Use jQuery I'm finding the expressiveness and simple approach amazing. The reasons for switching years ago may not apply as much. jQuery was slower for large amounts of dom changes but browsers have gotten better so this isn't as much of a concern for a normal website. I didn't get that messy feeling I would get when pages got too complex like thry would in 2007.. perhaps because I'm breaking things up differently. That might be because my understanding of javascript has increased since. Maybe jQuery was never the biggest problem with bloated frontends maybe I was.
- EB66 7y agoYeah, for smaller sites plain old manual DOM manipulations can work just fine. You're writing productive code right from the get go. No need to learn the nuances of a JS framework. But if the site or web app gets larger, I would want to use an SPA to eliminate manual DOM manipulations -- for both performance and maintainability reasons. jQuery still offers great utility in today's SPA world, but unfortunately the most popular JS frameworks have gone so far into developing their own domain specific languages and opaque rendering processes that most parts of jQuery can't be used with them. I wish more frameworks allowed components to be written in vanilla JS and had rendering that returned standard DomNodes.