Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript - DOM Selector Engine

Is there any selector engine for DOM elements like jQuery which offers no other extended methods like .bind, .css etc? What I mean is, a selector which just return found elements, nothing more. I tried to modify the jQuery, removed methods to get only the function that returns elements, but I got errors.

Thanks in advance!

like image 722
dpp Avatar asked Mar 04 '26 17:03

dpp


2 Answers

Have you looked at sizzle -

http://sizzlejs.com/

I believe it is the selector engine that jQuery uses.

like image 123
ipr101 Avatar answered Mar 07 '26 05:03

ipr101


If you code is intended to work only in modern browsers and the set of possible selectors is relatively simple (A.classA B.classB or something) you can use document.querySelectorAll with a thin wrapper over it or even do not use any frameworks at all.

As for old browsers, well, you always can try to implement it yourself, if size is so crucial for you. You can choose a tiny set of simple CSS selectors and use only them.

But, as well ipr101, I guess it will be better to use production-ready solution like sizzle.

like image 36
shabunc Avatar answered Mar 07 '26 07:03

shabunc