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
Top Dev
Top Dev11mo ago
Hello. Please DM
Jochem
Jochem11mo ago
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
Quest o()xx[{:::::::::::::::>
I am not sure if this what's you looking for https://jigsaw.w3.org/css-validator/
Hamza Naeem
Hamza Naeem11mo ago
Thank you, should I check manually in each file which style is used?
b1mind
b1mind11mo ago
PurgeCSS - Remove unused CSS | PurgeCSS
PurgeCSS is a tool to remove unused CSS from your project
Want results from more Discord servers?
Add your server