(deleted my comment on RwwL's answer to make it a thorough answer)
UnCSS , whether it is node.js or as a grunt or gulp task, can list the CSS rules used by an array of pages in a Media Queries array.
uncss: https://github.com/giakki/uncss
grunt-uncss: https://github.com/addyosmani/grunt-uncss
gulp -uncss: https://github.com/ben-eb/gulp-uncss
multi-page:
You can pass files as an argument to any of the three plugins, for example:
var files = ['my', 'array', 'of', 'HTML', 'files'], options = { }; uncss(files, options, function (error, output) { console.log(output); });
Avoid:
URLs (array):
An array of URLs to download using Phantom (on top of files that have already passed, if any).
NOTE. This function is deprecated, you can pass URLs directly as arguments.
Requests for the media and taken into account:
media (array):
By default, UnCSS processes only stylesheets with the media query "all", "screen" and those who don’t. Indicate here which others to include.
You can add stylesheets, ignore some of them, add inline CSS and many other parameters, such as htmlroot
Other problems:
1 / Conditional classes if you use them for IE9-. Obviously, they will not be mapped in the WebKit PhantomJS environment!
HTML: CSS: .ie9 .some-class { property: value; ] /* Only matched in IE9, not WebKit PhantomJS */
Should they be added manually or script to the html element in the test environment? (how it does not matter)
Is there an option in uncss?
Until you use the :not(.ie9) (weird) style, this should be fine.
EDIT: you can use the ignore option with the template to force uncss "to provide a list of selectors that should not be deleted by UnCSS". Will not be verified.
2 / Scripts that will determine the resolution (width of the viewport) and adapt content to it by deleting / adding it or adding a class to the container. They will be executed in PhantomJS in desktop resolution, I think, and therefore I will not do my work, so you will need to change the calls to PhantomJS or something like that ... Or look at the options or problems of GitHub from three projects ( me not)
Other tools that I heard about were not tested or barely or could not be tested, I do not know about the MQ part:
- in grunt-uncss readme, part of the coverage
- ucss from Opera (there is already an answer there, failed to get it to work)
- Helium
- CSSESS
- mincss
Addie Osmani has countless presentations with over 100 slides featuring amazing tools like this one: https://speakerdeck.com/addyosmani/automating-front-end-workflow (you will regret even more that the days are made only from 24 hours, not 48 err wait 72 ^^)