问题
I am trying to find out unused CSS class in my website, and then I found that there is a audit function in Chrome developer tools that will mark unused CSS classes. However, it is only doing one page at a time. Is there a way to make it audit multiple pages so that I can find out CSS classes that are not used in all pages?
I know there is a Firefox plugin Dust-Me that do the job. I am asking just to find if I can do that with Chrome alone, as I am more familiar with Chrome Developer tools.
回答1:
DevTools only runs against the currently-open page, so my hunch is, no.
You could install the Lighthouse CLI (it uses the same backend for finding unused CSS as DevTools) and then run Lighthouse against a list of URLs via a Bash script.
urls=("a.com" "b.com" "c.com")
for url in $urls; do
lighthouse $url
done
来源:https://stackoverflow.com/questions/42685819/is-it-possible-to-audit-multiple-pages-with-chrome-developer-tools