Qwery - The Tiny Selector Engine
It's true. The world needs another JavaScript DOM Selector Engine. So without further fuss - introducing Qwery - The Tiny Selector Engine. It's a port from where Simon Willison left off with his getElementsBySelector in 2003, and believe it or not, this is exactly where jQuery started.
Qwery supports all the basic CSS1 & CSS2 selectors, plus the additional (most important) attribute selectors from CSS3. Additionally it allows multi-selects (div,p) as well as context-aware selectors (like jQuery.find()).
Last but not least, it's open source awaiting your valuable feedback to make it leaner and faster. There are tests to ensure its integrity, however sans-benchmarks. Although, it should be noted it does support querySelectorAll when available in the browser (to bring 2003 to modern times).
Why all this?
When it comes right down to it, you often don't need a full blown selector engine suite. Qwery is 1k (gzip+min) which comes out to 1/4 the size the Sizzle. And on a day to day development basis, it's pretty rare to be seeking an obscure element collection from a query like div > p:lang:(en):nth-child(1n+0):not([data^="user-"])
. Seriously, who does that? (Maybe 2% of you are raising your hand).
Real world css queries
To put things into perspective, building #NewTwitter didn't require a single complicated CSS query beyond attribute selectors to retrieve data on nodes (which Qwery supports). Other than that, most queries were simple element/class descendent selectors. That being said, given the complexity of the application it's safe to say most applications will never need anything beyond what Qwery provides. So have at it and give it a play
Contributors
- Simon Willison for his awesome original work
- Jacob Thornton (co-contributor)
- Me. Hi.
- Future pull-requesters ;)
Cheers.
recent
- Matador: The Obvious MVC Framework for Node
- Sandboxing JavaScript
- Crouching Ender, hidden command
- Ender.js - The open submodule library
- Qwery - The Tiny Selector Engine
- Klass
- Smallest DOMReady code, ever.
- $script.js - Another JavaScript loader
- About that slowness on Twitter...
- Autocomplete Fuzzy Matching
- JavaScript Cache Provider
- JavaScript Animate
- Asynchronous method queue chaining in JavaScript
- Something changed
- Unofficial Twitter Widget Documentation