Unused CSS and JS Files
Hi there, I have a style.css, what if I want to check which classes are not used and have no use in the style sheet how could I find it?
And same for JS files/
5 Replies
Hello. Please DM
If you can help, please do so in open chat so that others can benefit from your answer as well.
To answer your question, Hamza, you can use the coverage tab in Chrome's dev tools to check, but it's a non-trivial process. Keep in mind that styles or code that aren't used on one page, might be used on a second one, or in different circumstances on the same one.
there are other tools, but I don't have any experience with them. Recently I've just been using Svelte, which takes care of that at a component level. Before that, I would just do it manually and accept the couple percent overhead my applications had, but that's also more of a luxury for an application developer where you know stuff like CSS will be loaded once and cached while a user loads dozens or hundreds of pages in your application
I am not sure if this what's you looking for
https://jigsaw.w3.org/css-validator/
Thank you, should I check manually in each file which style is used?
PurgeCSS - Remove unused CSS | PurgeCSS
PurgeCSS is a tool to remove unused CSS from your project