Search code examples
javascriptjqueryglossaryresig

What is a selector engine?


I've seen news of John Resig's fast new selector engine named Sizzle pop up in quite a few places, but I don't know what a selector engine is, nor have any of the articles given an explanation of what it is. I know Resig is the creator of jQuery, and that Sizzle is something in Javascript, but beyond that I don't know what it is. So, what is a selector engine?

Thanks!


Solution

  • A selector engine is used to query a page's DOM for particular elements, based on some sort of query (usually CSS syntax or similar).

    For example, this jQuery:

    $('div')
    

    Would search for and return all of the <div> elements on the page. It uses jQuery's selector engine to do that.

    Optimizing the selector engine is a big deal because almost every operation you perform with these frameworks is based on some sort of DOM query.