A Grunt task that removes unused CSS from your projects using UnCSS.
grunt-uncss is a Grunt plugin that removes unused CSS from web projects to reduce file size and improve performance. It works by analyzing HTML files to identify which CSS selectors are actually used, then generates a cleaned stylesheet containing only those rules. This helps eliminate bloat from large frameworks like Bootstrap when only a fraction of their styles are utilized.
Frontend developers and build engineers using Grunt as their task runner, especially those working on multi-page websites or applications with large CSS frameworks.
It automates a tedious manual optimization process, integrates seamlessly into existing Grunt workflows, and can significantly reduce CSS payloads—sometimes from over 120KB down to 11KB—leading to faster page loads.
:scissors: A grunt task for removing unused CSS from your projects.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Integrates UnCSS to automatically strip unused styles, drastically reducing file sizes—e.g., from over 120KB to 11KB for Bootstrap, as shown in the demo.
Can process multiple HTML files or remote URLs, enabling site-wide CSS cleanup; examples include scanning localhost URLs for dynamic sites like WordPress.
Allows ignoring specific selectors for dynamic content and reports minified or gzipped sizes to track optimization gains, though gzip reporting slows builds.
Works with other Grunt plugins like grunt-processhtml for rewriting stylesheet references, fitting into existing automated build pipelines.
The underlying CSS parser struggles with complex selectors like attribute combinators, causing build errors and requiring separate stylesheet management, as admitted in the limitations section.
Exclusively tied to Grunt, making it unsuitable for teams using modern task runners or bundlers like Gulp or Webpack, limiting its relevance in contemporary frontend stacks.
Enabling gzip size reporting can increase task duration by 5-10 times, adding significant slowdowns to build processes for marginal insight.
Requires manual configuration to ignore dynamically added selectors; if overlooked, it can strip necessary styles, breaking functionality in JavaScript-heavy applications.