Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 781
pbh101 Avatar asked Aug 25 '08 16:08

pbh101


People also ask

What is CSS selector engine?

If you're wondering what a “CSS selector engine” is, it's simply a grandiose term for functionality that matches a set of DOM elements given a CSS selector expression. For example, all elements that have the class ninja can be collected with the selector expression .

What is Sizzle Selector?

Sizzle is a JavaScript selector library that offers powerful ways to select elements. You can select based off text contained (or not contained) within elements, the existence of child elements inside a parent, or if those elements do not exist.

What are selectors in jQuery?

jQuery selectors allow you to select and manipulate HTML element(s). jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.

What is JavaScript selector?

JS uses the CSS syntax to select and manipulate HTML elements. Selectors are used to "find" (select) HTML elements based on their tag name, id, classes, types, attributes, values of attributes and much more. A list of all selectors can be found in our CSS Selector Reference.


1 Answers

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.

like image 125
Dave Ward Avatar answered Sep 21 '22 13:09

Dave Ward