3 ms·
I'm certainly not a jQuery fanboy, but jQuery's DOM-manipulation functions are certainly more concise and abstract away some of the funky internals (NodeLists,
by benesch 14y ago
I'm certainly not a jQuery fanboy, but jQuery's DOM-manipulation functions are certainly more concise and abstract away some of the funky internals (NodeLists, etc.).
That said, I've always found jQuery's function naming to be particularly ambiguous. There's no indication that "find" searches an element's descendants for a matching CSS selector based on its name. On the other hand, vanilla JS's element.getElementsByTagName is so much more verbose. Back in the day I found PrototypeJS [0] to be much better organized and offer the same feature set, but it's largely fallen out of use since Rails dropped it. mootools is nice but the docs, while comprehensive, are arranged in no logical order. Every time I try to pick up mootools I end up running around the docs in circles.
tl;dr jQuery is overblown but I think there's room for improvement over vanilla JS.
Plus there's always the (literally) hundreds of plugins for every possible application of jQuery.
[0] http://prototypejs.org http://prototypejs.org
- emn13 14y agoI actually like long verbose names. Unfortunately, plain JS names are often long, verbose and unclear, so that's not a win. (e.g. document.querySelectorAll - that should have made some reference to css; and "all" should be implicit as it is the norm in CSS). I'd love to see a JS library that doesn't try to add a lot of functionality, but only decruftify the browser API. The right aim would be to end up with a complete API that might actually replace the normal JS api (DOM+otherwise) in actual browsers.
- eze 14y agoWhat do you think of Zepto?
- jacobr 14y agoIt's not necessarily a bad thing that DOM-manipulation functions are a bit annoying to type. Verbose names means that you are more likely to do: var elem = document.getElementsByClassName('foo')[0]; elem.fooBar(); elem.foo = 'bar'; rather than $('.foo').fooBar(); $('.foo').foo = 'bar'; even if you don't know anything about writing optimized JavaScript code.
- benesch 14y agoBut sadly, beginners these days learn "jQuery" before they learn JavaScript.