DEV Community

Discussion on: Hating jQuery doesn't make you cool

Collapse
andreasvirkus profile image
ajv • Edited on

An interesting post, Tyler, thank you for it. While I agree that there's a tool for every job, I can't help but wonder why reach for jQuery when libraries like zepto and cash are a tenfold smaller and also more performant? they give you almost all the features and allow you to plug in all the same plug-ins. Also there are other great behavior and interaction targeted libs like alpine.js that I'd recommend checking out. I feel like fighting for jQuery in 2020 is more of a novelty thing and people not willing to let go. At this point, I'd feel safe to say that if you can support evergreen users, you should never reach for jQuery (even if you check all your listed criteria), simply because there are more lightweight options available that fit the bill.. And while you can still argue that the couple tens of kilobytes are irrelevant, adding a few plug-ins of the same size really adds up (and I feel $ plugin developers are notorious for bloated code that you can't treeshake nor import dynamically with ESM etc).

Would love to hear your thoughts on my take 🙏

Edit: just re-read my reply and I wanted to emphasize that I agree with you in the larger sense, just not specifically on the jQuery bit itself 100% 😅

Collapse
tylerlwsmith profile image
Tyler Smith Author

WordPress powers 35% of sites on the Internet, and the majority of those sites are already using the copy of jQuery that's bundled with WordPress on the front end. This is even true with custom built themes: almost all of the popular WordPress form plugins use jQuery. That means almost 1/3 of sites on the Internet have already paid the jQuery penalty. If you do development on a WordPress site, you're almost certainly sending down extra bytes by including Alpine or friends.

Except it's not just WordPress. W3Techs estimates jQuery to be used on about 75% of sites on the internet.

These newer, more performant libraries are pretty cool. But most of them are developed largely by sole maintainers who could walk away at any time. jQuery–for better or worse–will outlive us.

Every time I hear talk about jQuery's performance and "right tool for the job," I'm reminded that there are a decade of "Ruby on Rails is Dead" posts floating around the Internet. Surely with Elixir, Rust, and Go, there's no reason to write Ruby on Rails in 2020!

Except there's enormous business in boring tools. Airbnb, Groupon, Github, Couchsurfing and Shopify use Rails, and they know that the future of the framework is secure. If their entire engineering department was hit by an astroid, they'd be able to find more Rails developers and the framework would still be around. Mega companies still use jQuery in their stack for the same reason: the best technology available isn't always the best technology for the business.

jQuery isn't the right tool for every job. It's not what I use the majority of the time in my day job. But it's still relevant in 2020, and it will likely still be relevant for at least another decade.

Collapse
andreasvirkus profile image
ajv

Everybody always mentions bytes sent over the network, and that's great to keep in mind, but your gzip number only tells half the story. That prepaid ~30kB network cost that you save is still 86kB of raw JavaScript for the browser to parse, every time.

And as you bring up enormous tools like GitHub etc, note that almost all of them opt for vanilla JavaScript that gets sprinkled in sparsely, and not an outdated library that costs a user a tenth of a MB to parse 🤷‍♂️

But I obviously can't dispute that this little conversation could change anything and that we'll of course see jQuery and friends stick around, and that's okay.