CSSselect is CSS selector engine. It returns a function that tests elements if they match a selector - checking needs to happen "from the top", like browser engines execute queries.
Just take the following CSS query:
foo bar baz. When the element named
baz has like a billion children, every one of them needs to be checked if they match a query. Three times, to be precise, if you run a CSS query from the start to the end (as e.g. JSDOM does). Yup, that's slow.
This library checks every element once. The more complex the query, the greater the benefit.
By stacking functions!
- The API needs to be improved
- Documentation needs to be written