Just Use jQuery
twitter.com
twitter.com
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.
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!
$(“.submenus”).hide()
vs let submenus = document.querySelectorAll(“.submenus”);
for (let i = 0; i < submenus.length; ++i) {
submenus[i].style.display = “none”;
} document.querySelectorAll("p").forEach(e => e.style.display = "none") for (const e of document.querySelectorAll("p")) { e.style.display = "none" } 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();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.
jQuery syntax is clean, it works, why change that?
1: Just use apache + php
2: Use microservices, service meshes, k8s etc.
3: Just use apache + php
Cheap joke though, although it was fun, applications and demands have changed. Especially in the environments I work in today. Although I often, as an excersize, question myself why stuff got so complicated and if this really is the way it should work. And tbh, sometimes the answer, in my opinion, is no.
Then the first maintenance came. _"Not worth it"_ doesn't even begin to cover it.
If you have both:
a) Well designed microservices that follow the 12 Factor App principals _fully_ b) A team of (minimum) five to dedicate solely to K8s maintenance
Sure, go for it. How many people using K8s can tick both of those though?
If you want something reliable, easy, and (almost) maintenance free; Just use AWS Lambda + API Gateway (or whatever Google and Microsoft equivalents you have).
I also quite enjoyed Svelte.
I have very little interest in touching the DOM imperatively when a declarative option exists.
Even just a naive approach of plopping a whole page in one big component or enhancing a page rendered elsewhere by mounting a few self-contained widgets on it is nicer than manually keeping track of state with events. Even my best an most concerted efforts at jQuery frontends eventually had many bugs that simply don’t happen with a declarative approach.
It's just too slow and convoluted to do that (I tried), and this gets even worse with TypeScript because tsc is so darn slow to startup.
The closest I've gotten is running the JavaScript build system as a subprocess in the application itself, but meh...
They even describe it as a "declarative replacement for jQuery" in the docs!
https://github.com/FranckFreiburger/vue3-sfc-loader
Might be worth trying. The problem is that these 3rd party libraries may work but you may end up needing a build system for a new library that you may need in the future.
I tried but for complex applications with JS, you unfortunately cannot get away from the build system.
I never got the hype honestly. However I have been happy with my stack ever since, would I be 10 years younger I may would do node and react as well.
I'm not saying jQuery or vanilla JS (which is the same thing, just a different API) is the end-all of everything, but with a bit of care and organisation it's not too hard to make dynamic "modern" sites and even web apps that are fast and can be maintained fairly easily. It is easy to make a mess of things though, as it doesn't guide you through a "framework" and especially in larger teams with different experience/skill levels this can be an issue.
At the end of the day I think this is a "Python vs. Ruby" type of discussion, where both can obviously work well, but both obviously also have their own strengths and weaknesses.
I dislike a certain section of the frontend crowd who thinks that going full-in on WebPack+React+TypeScript+1561 dependencies is the only possible way to build something useful and derides anyone who disagrees (at some point someone called me "the anti-vaxxer of frontend development" over this).
jQuery and PHP's ease of integration was what helped get me from HTML + CSS to interactive websites.
Long may they continue.
i've seen a ton of react apps that had no business being react apps
I have 2 production Svelte projects completed, and it is a charm to work with.
I think as coders we feel most comfortable reaching for JavaScript first, when really we should be doing as much in HTML itself as possible, then prettying it all up with CSS, and then finally adding some JS for interactivity such as client side form validation.
You can work around them, but you’re approaching the complexity of just writing your own validator by that point.
The DOM API does not spark joy.