I have to say that I think this option is better than my original recommendation; my original recommendation was great for quick looking, this is better for making release packages.
UnCSS and specifically what I'm basing the recommendation off of is The Grunt wrapper for UnCSS; that of course integrates into the Grunt build system for great automation.
There is a fair bit of customization options (listed in detail too), and it supports both local and remote css files as the sources.
If using in Grunt I suggest using it in tandem with grunt-processhtml to automagically make your page(s) reference the new concatenated and cleaned css file(s).
How I use it: (a snip of my gruntfile.js)
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uncss: {
main: {
options: {
report: 'gzip'
},
files: {
'<%= grunt.option("outpath") %>/css/cleaned.css' : '<%= src_files_html %>',
}
}
},
processhtml: {
main : {
options: {
strip: false
},
files: [{
expand: true,
cwd: '',
src: '<%= src_files_html %>',
dest: '<%= grunt.option("outpath") %>'
}]
}
}
and then in my html file I have this:
<!-- build:css ./css/cleaned.min.css -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
<link href="./css/style.css" rel="stylesheet">
<!-- /build -->
which is transformed into:
<link rel="stylesheet" href="./css/cleaned.min.css">
and the CSS is a lot smaller and better for performance and mobile bandwidth.