Query html files with css selectors


#1

Use-case: I have a bunch of css rule that are too general and I have to track down where they are used.

It would be nice if I could query all my html files with a css selector instead of having to use a regular expression.
I’m not sure if there are any existing libraries that allow jQuery like behaviour to search files without having to render the dom. The closest thing I’ve found is xpath queries in another editor.

Apparently there are node.js implementations that allow the usage of jQuery: Cheerio and jsdom are two that I found.
Are they overkill to build a search function with?
How can I implement a custom search filter?


#2

That is an interesting idea, I think the attempt to load things in the dom so you can use jquery will either be too slow or lead to memory crashes. Instead, I would look to converting css selectors to regexes. I’m not sure of any libraries that do it currently but it would certainly be faster.