That's a big part of it. I've seen websites from my schoolmates back in the day where the entirety of jQuery was loaded just to use $.trim(). The developer never made anything without a library like jQuery, and apparently doesn't realize that Vanilla JS already has a trim function, I guess?
In many cases, jQuery "fixed" stuff that was missing in some browsers, or which had issues. I remember specifically the AJAX stuff, for instance. jQuery's trim is deprecated (since last year!)- there's a chance that at some point it was useful (or it might not, but jQuery is mostly reasonably well-designed. I think having a trim *function* might be because it's useful to be able to invoke it on nulls.
These are the types of developers university-level CS programs are graduating nowadays. They don't teach you anything that makes you a legitimately useful employee, they just train you to be a mathematician whose talents are better used in some stuffy office in the bowels of a university math/CS department, but can't actually write 10 lines of elegant, readable, usable code.
CS = Computer Science != coding. While I'm sure university could produce people who are better codes without detriment to producing academics (both academics and coders are required in this world), I could also say that it's likely there should be specific career paths to become a professional coder, and to become an academic.
I work with Java, and the number of times I see import org.whatever.* instead of the particular package that you're actually using is effing maddening.
I'm sure there are worse things that are bothering you on those pieces of code.
The way you import libraries in JavaScript is fricking stupid. JavaScript, in general, is just plain stupid. The only solution without breaking billions of lines of code would be a preprocessor for JS like there is for CSS... like SASS, or something. Is there one? I don't really do front-end development. Not really sure that SASS does what I'm talking about, TBH, only used it briefly.
You mean Typescript. Or any of the languages that compile to Javascript or WASM. This weekend I finally pushed a first operating version of a PWA I'm writing as a side-project with Rust- you are certainly not forced to go through Javascript.
If you are writing a non-heavily dynamic website, then you don't need to write a ton of Javascript, and then it's tolerable. If you have to do a very dynamic app-like-thing, then investigate TS or whatever (Elm, Clojure, the Haskell-JS thing, etc.).
Partial answer to the question:
Javascript can be really useful. I never really liked it, but now on my personal site I use it to adjust zooming on iPads and iPhones, especially when rotating the device from portrait to landscape or the other way around, as well as delay loading lots of images and more.
Obviously, it's important to keep in the back of your mind that people may not have javascript, and the page/site still needs to work. I do keep that in mind, but I have to be honest: I rarely test for this. Lazier people will just not think about such issues at all.
It's démodée to do progressive enhancement, but back in the day I tried doing that and it didn't work so badly. You basically sprinkle JS on top of a working page without JS. It's hard to remember to keep testing without JS when making changes, but if you do things in a certain way, it's likely that your website will be mostly functional on NoScript.
That being said, I have no idea how the web became this cesspool of inscrutable javascript code that does stuff that can easily be done with plain HTML and CSS.
Again, people being lazy and applying JS frameworks to pages that do not require that. There's a case that can be made about that being cost-effective, and that only a minority cares about the drawbacks.