> I mean, you normally abstract these things with a helper fn or two, without importing the whole jQuery anyway.
Add enough helper functions are you're at jQuery anyway. Looking at the jQuery source code, it manages a lot of edge cases that I don't really have time to figure out on my own.
The DOM API isn't really designed that well for human consumption.
> Add enough helper functions are you're at jQuery anyway.
I really hate these exaggerations. jQuery is, last I checked, over 200k unminified. Anyone writing enough helper functions to get to a fraction of that is already a pathological case.
Browsing the source of jQuery and I don't find it bloated but I find a lot of knowledge in there that a naive user the DOM API would most likely know about.
It's kind of like how you can comparing languages using simple example code isn't relevant because proper code with full error handling and edge case handling can be very different from a naive example.
The point is that this is a strawman. "Enough helper functions" to get to jQuery is 288580 bytes. A quarter of that, or even a tenth of that, is already a pathological case and way beyond almost every case of "jQuery substitution" that would happen in practice.
> Looking at the jQuery source code, it manages a lot of edge cases that I don't really have time to figure out on my own.
Reminds me of the warning about rewriting old "messy" codebases. I am paraphrasing, but the upshot was "You know what those weird and ugly bits of code are? They're bug fixes, and they were earned through sweat and blood and years over a period of many, many years."
I don't find the jQuery API to be particularly friendly. It tries to be cute and ends up being annoying. Its implementing code is also an abomination, so not particularly helpful. I'd rather read through Gecko internals than try to figure out what the hell a jQuery helper actually returns.
The DOM is at least very, very well documented. jQuery has documentation, but it's not even close. It gives away what jQuery always has been, which is a library that is aimed mainly at assisting bag-of-tricks StackOverflow programmers than people who actually want to understand their programs and the object graph they work on.
IE 11 hits it’s EOL next month. So, really probably not a whole lot of reason not to just pull the trigger and inform everyone that complains of this fact.
jQuery emerged from the market and it's pretty close to what developers wanted to express.
JS is design by a committee full of people afraid to come out as "not-as-kind" and completely detached from reality.
True, doing some of the things which were half an hour on stack overflow or 1 line of jQuery became a couple of lines of vanilla JS but the API is still pretty awful.
Think about XHR > fetch vs $.get or $.post
I agree, I'll try to use vanilla JS and google something when I need to ship some code - but for hacking around I'll just bring in jQuery and write 1-liners at blazing speed.
A lot of times the jQuery syntax is easier to understand (IMO).
Remove element exmample:
jQuery API:
DOM API: or if you want to introduce another variable just to remove the element: Create element example:jQuery API:
DOM API: I know which ones I'd rather write and read.