« Back to Index
Thoughts re: UnCSS (a way to parse CSS files to see if all of the rules/selectors apply to a HTML page)
View original Gist on GitHub
UnCSS.md
There are a couple of steps (and issues) that need to be considered for a solution to present itself…
- Load CSS
- Check each rule’s list of selectors
- If the selector is a
class
or an id
then we can just see if it appears in the HTML markup
- If it’s neither a
class
or an id
then we’ll need to somehow parse the HTML and see if the CSS applies
- But how do we work around HTML that is post loaded via JavaScript?
- This is where using a headless browser would be required, and if that’s the case we may as well go headless completely
- We need to check each media query found and see if selectors within match at some point
- The same process as above needs to happen (if
class
or id
then we can just check HTML markup)
- Otherwise we’ll need to parse HTML to see if the CSS applies