Are there any good approaches to help identify unused css definitions in a project? A bunch of css files were pulled in and now I'm trying to clean things up a bit.
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Faster loop: foreach vs some (performance of jsper
- Why wrapping a function into a lambda potentially
- Add animation to jQuery function Interval
Use Internet Explorer Developer Toolbar,s View > CSS Selector Matches: View a report of all style rules set and how many times they are used on the current page.
Take a look at the Firefox extension Dust-Me at https://addons.mozilla.org/en-US/firefox/addon/dust-me-selectors/.
I have just found this site – http://unused-css.com/
Looks good but I would need to thoroughly check its outputted 'clean' css before uploading it to any of my sites.
Also as with all these tools I would need to check it didn't strip id's and classes with no style but are used as JavaScript selectors.
The below content is taken from http://unused-css.com/ so credit to them for recommending other solutions:
It looks like someone updated DustMe Selectors to work with Firefox again under a new name - 'CSS Roundup' http://blog.brothersmorrison.com/?p=198
Google Page Speed can do that for you (it actually does a whole lot more than just telling you which CSS is unused). On FireFox, it is available as a FireBug add-on. Then there is an online version too.
A Better CSS Minifier in C# dumps redundant styles;
You would also want to use Dust-Me with this.
Keep in mind, if there is any content that is not currently visible to dust-me, you might throw out styles you need.
EDIT: link was broken but archive.org has both the page and the code.