Post by @fasnix
WebDev:
Is there a tool that allows pasting HTML and CSS in two separate fields and compares them to show, which CSS rules are not used in the HTML file?
Downloaded a template and the CSS seems to me awfully bloated!
(vibe-coded by an "AI-Wizard")
5 likes
@fasnix @nocci
There are quite a few tools that can extract, what is really needed.
But it is not as simple as it sounds. A lot of CSS rules are made dependent on the actual screen dimensions. Some rules may not be used on a large screen, and so on.
Others may be used only when certain JavaScript is triggered.
@fasnix you can use DevTools in Chrome with the Coverage tab to get an idea. But that runs on a live page. And as another replily mentioned, non-matched media queries and non-triggered interactions will make skew the numbers towards more unused CSS than is the case.
@kaleb@haugenh.us
Thanks, however the link I wanted to test produces an 502 error.
Maybe, because it's on a subdomain?
@fasnix hmm. I haven’t had that problem, but it sounds like an issue on your server.
There are other tools that work offline you might want to try, like this one for VSCodium/VSCode: github: robwizzie / unused-css-detector
@kaleb@haugenh.us
Well, it's not my server, I tested a template on another server/subdomain.
Thanks, I'll check the tool tomorrow.