
How to Switch from JQuery to Vanilla JavaScript with Bootstrap 5 - kiyanwang
https://www.freecodecamp.org/news/bootstrap-5-vanilla-js-tutorial/
======
noble_pleb
Is it worth switching from jquery with all the extra verbose code you must
write for DOM manipulation?

~~~
austincheney
Yes, absolutely.

First of all if you use querySelector or querySelectorAll for everything your
code will likely be smaller without jQuery, but it will be just as slow.

If you access the DOM with string parsing your application can be anywhere
from 1200-10000x faster. It will be more verbose, but certainly not as much as
most people fear. If you are good with scope and abstractions you will solve
for most of the verbose DOM interaction with reuse and custom abstractions.

So really dumping jQuery means choosing between smaller code or substantially
faster code and both are a win.

~~~
noble_pleb
Opinions vary on that one, does a footprint reduction by 90kb really matters
in the day and age where megabytes of bloatware like angular, react, vue, etc.
goes unchecked?

If adding 90kb helps me write `$(document.ready()` instead of
`window.addEventListener(DOMContentLoaded)`, I'd rather add that because
making code more intuitive and readable is what software engineering is about.

~~~
austincheney
I prefer to assign events handler's directly to node event properties instead
of addEventListener. The only advantage to addEventListener is that you can
plug in a bunch of marketing spyware nonsense without worry that its going to
clobber your event assignments.

