UnCSS is a tool that removes unused CSS from your stylesheets. It works across multiple files and supports Javascript-injected CSS. UnCSS cannot be run on non-HTML pages, such as templates or PHP files. If you need to run UnCSS against your templates, you should probably generate example HTML pages from your templates, and run uncss on those generated files; or run a live local dev server, and point uncss at that. UnCSS only runs the Javascript that is run on page load. It does not (and cannot) handle Javascript that runs on user interactions like button clicks. You must use the ignore option to preserve classes that are added by Javascript on user interaction. UnCSS can also be used in conjunction with other JavaScript build systems, such as Grunt, Broccoli or Gulp! Note that you can pass both local file paths (which are processed by glob) and URLs to the program.

Features

  • The HTML files are loaded by jsdom and JavaScript is executed
  • All the stylesheets are parsed by PostCSS
  • document.querySelector filters out selectors that are not found in the HTML files
  • The remaining rules are converted back to CSS
  • UnCSS can also be used in conjunction with other JavaScript build systems
  • Supply the options used to create the JSDOM pages
  • Give the task a raw string of CSS in addition to the existing stylesheet options

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow UnCSS

UnCSS Web Site

Other Useful Business Software
Save up to 90% off rates for USPS, UPS, DHL Express, and more with the best multi-carrier shipping software for e-commerce businesses. Icon
Save up to 90% off rates for USPS, UPS, DHL Express, and more with the best multi-carrier shipping software for e-commerce businesses.

For Small / Medium E-Commerce Businesses

Whether you're established or just getting started, Shippo is the best shipping software for growing e-commerce brands that need to save time and money, fulfill and ship at scale, and delight customers. Create shipping labels for all carriers & save money with discounted rates. See all your online sales channels in one place and automatically access discounted USPS and DHL Express rates, or use your own carrier accounts. Sign up is free and there are no monthly fees or cancellation fees.
Learn More
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of UnCSS!

Additional Project Details

Programming Language

JavaScript

Related Categories

JavaScript Software Development Software

Registered

2022-06-15