style-broom
v1.0.1
Published
Remove unused CSS from <style> tags in HTML
Downloads
4
Maintainers
Readme
style-broom
Remove unused CSS from tags in HTML
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