Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
glenn romaniuk
33,738 Pointstool to list unused css selectors
I have the task of merging a couple of css files Beside doing this manually is there a tool that would give me a list of used/unused selectors for a given # of pages?
2 Answers
Dave McFarland
Treehouse TeacherThere is a tool called UnCSS that does just that. It uses node.js to remove selectors that aren't used in the specified web pages. You need to install node.js to use it. You can find UnCSS on GitHub at https://github.com/giakki/uncss
You can also use UnCSS with popular "build tools" like Grunt, Gulp and Broccoli (yes, those are real things believe it or not.) Here's an article that provides an overview of using UnCSS with Grunt, Gulp and Broccoli (you only need to choose one of those, and my favorite is Gulp): http://addyosmani.com/blog/removing-unused-css/
Warning: you should have a pretty good grasp on using the command line and JavaScript to use any of these tools. I'm not sure if there's a simpler, desktop program that can handle the task -- if there isn't I think people would pay good money for one!!!
Good luck and let us know how it turns out.
James Barnett
39,199 PointsJames Barnett
39,199 PointsHere's an article that talks about using Grunt with uncss
http://xdamman.com/website-optimization-grunt-uncss