Thursday, March 26th, 2009
Remember when we thought there may be less CSS selector engines? :) Instead we have renewed performance-based competition among them.
Sly is the latest selector engine created by Harald Kirschner.
To use, it looks like this:
- // Finds all odd rows in all tables
- var rows = Sly.search('table td:odd');
- // Finds all links with class "internal" and an attribute "href" starting with "#".
- var links = Sly.search('a.internal[href^="#"]');
- // Another notation is also possible, since Sly acts as a constructor
- // features is just one element, lists has all list items are siblings of features
- var features = Sly.find('#features');
- var lists = Sly.search('~ ul', body);
What does it feature?
- Extra optimizations for frequently used selectors and latest browser features
- Works uniformly in
DOMdocuments, fragments or
- Utility methods for matching and filtering of elements
- Customizable pseudo-classes, attribute operators and combinators
- Just 3 kB! (minified and gzipped, 8 kB without gzip)
- No dependencies on third-party JS libraries, but developers can override internal methods (like
getAttribute) for seamless integration.
- Code follows the MooTools philosophy, respecting strict standards, throwing no warnings and using meaningful variable names
And it comes with speed tests:
Posted by Dion Almaer at 11:37 am