Is there a way to script a CSS audit? I just need file-level info, not individual rules. Seems like the page has to actually render in order to get accurate info… so maybe something like Selenium could help?
I've seen that there are browser plugins to audit CSS files (e.g. this StackOverflow question, this A List Apart article), but manually reviewing results for every page would take too long
Background
Over the years, various CSS files have crept into our web app's template header. It's a huge pain trying to style an element when there are overlapping rules from multiple frameworks, plugins, etc all fighting for supremacy.
As part of an attempt to consolidate/standardize, I'd like to move older references out of the site template and into the individual page headers, so the CSS rules' affects will be limited to only where they are used/needed.
I'm thinking the easiest thing would be to crawl the site and track which CSS stylesheets are used where.
UPDATE
Unintentional rule matches are possible, so I'm starting to think I can't script this. We'll probably have to go page-by-page. Even then, the styling of some pages might rely on the strange intersection of opposing stylesheets :-/
Also, I'm skeptical of these static CSS checkers, especially with template files. The rule ul > li.special
might not match anything until runtime (elements could be created server side or javascript)