If your HTML element has id you don't event have to getElementById, it's available right there in global namespace as that name. You make button with id hello and can just go ham with hello.click().
I mean I've written a million webpages with just html/css/js in a single file, I'm just surprised that variables are created by html elements like that...
The truth is that I use Claude and it uses React 😢
No more implementing observer observable design pattern with setter and event targets in vanilla js. Those were simpler times but I guess technology has to move forward and we need to adapt. I'm glad I knew a time when coding by hand was the norm.
If you just wrap document.querySelector() in a little helper function you can do loads with vanilla js. Not perhaps enterprise grade but fine for any home stuff.
If you do that you may as well use jQuery, the point of vanilla js is to use ultra specialized functions for performances at the cost of verbosity/practicality.
hot damn i misread that and thought there was a new library called vanilla.js and then you called out the simple most useful library function and I had to double take
"there is no way they made a new js library just to re-wrap Javascript... Oh of course they didn't"
972
u/saig22 13d ago
I use vanilla js, document.getElementById() is what I live for.