1.0.1 • Published 7 years ago

style-broom v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

style-broom

Remove unused CSS from tags in HTML

Travis npm

An uncss-like tool for removing unused CSS from HTML, but it only operates on <style> tags, and only performs static analysis.

Used by Scow, an email inliner and bundler, to remove unused CSS, saving precious bytes on HTML emails.

Installation

npm install style-broom

Usage

const styleBroom = require('style-broom');

const html = `
<html>
  <head>
    <style>
      .unused {
        color: red;
      }

      .used {
        color: blue;
      }
    </style>
  </head>
  <body>
    <p class="used">style-broom</p>
  </body>
</html>
`;

styleBroom(html);
/*
<html>
  <head>
    <style>
      .used {
        color: blue;
      }
    </style>
  </head>
  <body>
    <p class="used">style-broom</p>
  </body>
</html>
*/

API

styleBroom(html)

Given a string of HTML, look for any unused CSS selectors in inline <style> tags, and remove them.

  • html (String): input HTML.

Returns modified HTML.

Local Development

git clone https://github.com/gakimball/style-broom
cd style-broom
npm install
npm test

License

MIT © Geoff Kimball