4 ms·
jQuery is beautiful and meticulously engineered (and also modularized) to a level far beyond other DOM manipulation/cross-browser compatibility/animation/promis
by pcthrowaway 12y ago
jQuery is beautiful and meticulously engineered (and also modularized) to a level far beyond other DOM manipulation/cross-browser compatibility/animation/promise/wart abstraction/whatever else libraries. It may not be the best at everything, and it's certainly not minimalist (though its components are now designed to be independent and customizable) but it is the meeting of many good practices and informed design across its many capabilities. It's the everything-and-the-kitchen-sink philosophy (with a focus on performance).
> Given that all of the other libraries implemented a comparable selector engine
This is not true; other libraries implement their own selector engines which, while (sometimes) smaller in size, are also less feature-rich. Sizzle (jQuery's independently developed selector engine) provides many additional selectors not currently available in the browser (such as nested pseudo-selectors: `:not(:has(div:first-child))`).
If none of this appeals to you, you are welcome to use a different library. There are lots of other strong options. But just because jQuery doesn't fit your needs doesn't make it 'an abomination'
- oinksoft 12y agoYou're right that Sizzle was the class of selector engines, and if the story ended there (with jQuery as a DOM library) then jQuery wouldn't be listed on many resumes. By publishing `jQuery.prototype' to `$.fn', pushing the idea of "plugins", and by encouraging DOM operations as the main extension point in application design, jQuery made itself into something more. The brittleness of this approach is proven by how calling jQuery UI component methods requires an additional level of dispatch. This way of doing things has no legacy. It's considered an antipattern now, and a "mess of jQuery" is a known form of code debt. I don't think it's a matter of whether this style "fits your needs" anymore.
- pcthrowaway 12y agoA "mess of" anything is a known form of code debt. Just because jQuery doesn't force you to use it properly doesn't make it unusable. jQuery, or parts of it, are still used by default in almost every SPA application framework, and some of the resulting applications are even well structured.
- moron4hire 12y agoWhat do you do with these sort of extremely specific selectors?
- pcthrowaway 12y agoJust a very common use case for jQuery selectors is the :even and :odd extension, used to apply classes to table rows in order to alternate shading to make them easier to read.
- moron4hire 12y agoThat's pretty simple. You mentioned much, much more complex stuff.
- pcthrowaway 12y agoThere are many capabilities sizzle.js provides that go beyond CSS specifications (and also in some cases that are in the specification, but not yet implemented by browsers). Selectors can get pretty nasty, and having more flexibility available can help to make them more manageable. A lot of times you wouldn't want to use the more complex selectors, but it's certainly nice to have them.