Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox addon to find Unused CSS styles [duplicate]

Possible Duplicate:
Tool to identify unused css definitions

Lets say I have a page displayed in my browser and I have a .CSS file used on this page with rules like

    .class1{
    /* some style definitions */
    }
    .class2{
    /* some style definitions */
    }
    .class3{
    /* some style definitions */
    }
....
...
.class1001{
    /* some style definitions */
    }

Now my question is is there any addon which would tell me like out of these rules, which are "NOT USED" on the page..

I saw some related questions which provide links to addon that tell CSS selectors which are used on a page..But I have like 1000+ rules and hence want to directly know RULES which are NOT used..

JUST TO ADD, the addons mentioned have 1 issue; Like if there are hacks for IE (e.g. *html), it marks them as UNUSED, even though it is actually used in IE. Is there any workaround for this ?

Please help me. Thank you.

like image 522
copenndthagen Avatar asked Aug 22 '11 12:08

copenndthagen


People also ask

How do I know if I have unused CSS in Firefox?

Next, click the settings icon > More tools > Coverage. After that, click the Reload button (the circle arrow icon). Filter the list that appears to only see JavaScript or CSS resources. Click any resource to see the used and unused code.

How do I find unused CSS projects?

This Coverage tab helps us find unused Js and CSS code. Open your Chrome browser, go to “Developer Tools”, click on “More Tools” and then “Coverage”. A Coverage will open up. We will see buttons for start capturing coverage, to reload and start capturing coverage and to stop capturing coverage and show results.

How do I get rid of extra CSS?

If you want to remove unused CSS entirely, you can use a tool such as PurifyCSS to find out how much CSS file size can be reduced. Once you get the CSS code you should eliminate, you have to remove it manually from the page.

How do I test CSS selector in Firefox?

Simply right click and click Inspect Element. This will bring up the CSS selectors for that element.


1 Answers

If you use Firefox, you can use the Dust Me Selectors plugin that does exactly what you asked for. It finds unused Selectors for you :) Give it a try!

Also there is the CSS Usage plugin, that looks over your CSS file and tells you which ones are not being used. :)

like image 101
Kyle Avatar answered Sep 21 '22 16:09

Kyle