Web development , php , ajax , symfony, framework, zend
In: web resources
27 Mar 2009Back in December when the Sizzle selector engine was announced, John Resig’s creation was thought to be the end game. Four months later it seems as though it was just the beginning.
Harald Kirschner has released Sly, a standalone javascript selector engine that absolutely tears through the DOM. Sly is a tiny 3KB minified and gzipped, supports all CSS3 selectors, and provides functionality to create your own custom combinators. Don’t believe me? Read Harald’s documentation.
// Finds all div blocks
blocks = Sly.search('div');
// Finds all anchors with `href` attribute that starts with `"http://"`
anchors = Sly.search('a[href^="http://"]');
// Finds all list item that are direct descendants of the list item with id `"navigation"`
items = Sly.search('ul#navigation > li');
// Finds all heading elements
heads = Sly.search('h1, h2, h3, h4, h5, h6');
// Finds all odd rows in all tables with the class `"zebra"`
rows = Sly.search('table.zebra tr:odd');
// Finds something and looks really complex
inputs = Sly.search('form[action$=/send/] label~span+input[type=text]:first-child');
That last one was something special, eh?
Join me in extending a huge congratulations and thank you to Harald! While Sizzle got the ball rolling, the selector engine game isn’t over by any means!
Don’t forget to follow me on Twitter and be sure to visit Script & Style for the best Javascript and CSS articles around!
This blog delivers stylish and dynamic news for designers and web-developers on all subjects of design, ranging from: CSS, Ajax, Javascript, web design, graphics, typography, advertising & much more. Our goal is to help you communicate effectively on the web with an engaging website or functional interface.