I want to have an automatical way to find unused CSS in a static HTML page (no javascript, all CSS code are embedded) and delete them.
I currently manually search for the unused CSS. But this is not efficient. It seems that there is not such a way yet. But I want to doublecheck to make sure.
EDIT: A standalone command line tool is preferred.
1. purify css
use this tool at this link: https://purifycss.online/
2. coverage - devtools
there is functionality on devtools called "coverage"
https://developer.chrome.com/docs/devtools/coverage/
that make you see how many bytes are used,
and how many aren't.
you can also use it to see what selectors aren't useful!
as mentioned by @quentin
the pseudoelements, pseudoclasses are red by default.
so try to debug the normal CSS with this dev tools tool.
3. make CSS to CDN
the tool that I suggest you is
jsdelivrwhy cdn?
cache: that makes your CSS cachable for a year,
saving time, and network resources.
minify: the CSS code will be minified,
simple: you can make every Github or npm file a CDN easily.
like this:
https://cdn.jsdelivr.net/gh/user/repo@version/file