3 ms·
Honest question from a backend developer: Is it still necessary to use JQuery in 2023 instead of vanilla js? I always had the impression JQuery was more useful
by elzbardico 3y ago
Honest question from a backend developer:
Is it still necessary to use JQuery in 2023 instead of vanilla js? I always had the impression JQuery was more useful to decouple you from the pain of multi-browser development in the 2000s dark ages of browser standards adoption.
- firecall 3y agoNot necessary, but you might like the jQuery API. I still use it as it’s a decent way to write succinct code to access the DOM. Makes me laugh that the same devs that claim you should use vanillaJS and that jQuery is bad are the same ones building React sites and using whatever else the latest JS trend is!
- srgpqt 3y agoThere is no need for jQuery nowadays. That said, it in still convenient. Compare: $(“.submenus”).hide() vs let submenus = document.querySelectorAll(“.submenus”); for (let i = 0; i < submenus.length; ++i) { submenus[i].style.display = “none”; }
- ent101 3y agoThis is a major reason why I still use jQuery instead of vanilla.
- ggx2 3y agoWhy not this? document.querySelectorAll("p").forEach(e => e.style.display = "none")
- WorldMaker 3y agoOr: for (const e of document.querySelectorAll("p")) { e.style.display = "none" }
- gabrielsroka 3y agowhy not const $ = s => document.querySelectorAll(s); const hide = e => e.style.display = 'none'; $('.submenus').forEach(hide); or, if you're okay with changing prototypes const $ = s => document.querySelectorAll(s); NodeList.prototype.hide = function () {this.forEach(e => e.style.display = 'none');}; $('.submenus').hide();
- SkyPuncher 3y agoHa. We actually just installed jquery in our code base recently for our Chrome extension. I can’t remember the exact use case. We probably could have done it in raw JS, but jQuery made a bunch of things much easier. Since it’s a Chome extension, package size didn’t really matter.
- rchaud 3y agoIt's no more necessary than Twig is compared to raw PHP. jQuery syntax is clean, it works, why change that?