For what I know, Sizzle and querySelector/querySelectorAll
are CSS selectors.
So... What is the difference between loading Sizzle and doing:
Sizzle("my CSS query")
and
document.querySelectorAll("my CSS query")
Also, I am aware that Sizzle returns an array of an element while querySelectorAll returns a NodeList (in most browsers). I am also aware that you need to load Sizzle and that you can use document.querySelector
for only one element.
So is there any other difference in performance?
EDIT: My question is only about the Sizzle selector engine (and querySelectorAll
). Please do not involve jQuery.
Sizzle is a pure-JavaScript CSS selector engine designed to be easily dropped in to a host library.
Its a spin-off of jQuery project they say, but when it comes to differnce between jQuery and Sizzle, JQuery is a library build to simplify javascript complex syntax that people found hard to understand and get a grid of specially the begineers. So if you are using JQuery, there is going to be a lot of overhead along with it where as sizzlers offer comparatively less.
Its preferred to use querySelector over Sizzler because its just an added overhead which can very easily be done with VanillaJS so why waste it. They both do the same thing.