Sizzle is a basic DOM selection engine utilizing CSS queries, available in most libraries available out there such as jQuery, Mootools, Ext, pretty much everything. Because of its overlap with the other libraries that your almost certainly have included in your project already the need for Sizzle is primarily for Custom Frameworks.
In enterprise, you’ll typically have one of these frameworks being worked on that isn’t based on an existing framework and has a really big need for great selector support, so Sizzle can probably find a really great niche there.
Using Sizzle is really easy, much to easy for a whole blog post really, but who cares. So here it is.
- // arrayOfResult is just a flat array.
- var arrayOfResults = Sizzle("CSS.selector");
- // Simple enough right?
- var allDivs = Sizzle("DIV");
- var divsWithBatmanClass = Sizzle("DIV.batman");
Its simplicity is really a large part of its beauty. Users who aren’t used to using a selector engine should start to grasp it pretty quickly, we don’t have a weird scalar($) value confusing those same people and it returns an array which has no special sauce attached to it for users to try to have to learn.No comments