Extract the CSS from an HTML document.
Install with npm
npm install --save extract-css
var extractCss = require('extract-css');
var options = {
url: './',
applyStyleTags: true,
removeStyleTags: true,
applyLinkTags: true,
removeLinkTags: true,
preserveMediaQueries: false
};
extractCss(document, options, function (err, html, css) {
console.log(html);
console.log(css);
});Type: Boolean
Whether to inline styles in <style></style>.
Type: Boolean
Whether to resolve <link rel="stylesheet"> tags and inline the resulting styles.
Type: Boolean
Whether to remove the original <style></style> tags after (possibly) inlining the css from them.
Type: Boolean
Whether to remove the original <link rel="stylesheet"> tags after (possibly) inlining the css from them.
Type: String
How to resolve hrefs. Required.
Type: Boolean
Preserves all media queries (and contained styles) within <style></style> tags as a refinement when removeStyleTags is true. Other styles are removed.
The code for this module was originally taken from the Juice library.
MIT © Jonathan Kemp
