Insert critical css into the first <style>
tag of an html file.
// atfcss.js
var atfcss = require('atfcss')
var path = require('path')
process.stdin
.pipe(atfcss(path.resolve(__dirname, process.argv[2])))
.pipe(process.stdout)
process.stdout.on('error', function () {})
$ cat critical.css | node atfcss.js source.html > final.html
var atfcss = require('atfcss')
Return a transform stream
. Pipe a CSS stream into stream
and get back a version of the HTML file at htmlPath
with the CSS inserted into its first <style>
tag.
This package also comes with a atfcss
command:
usage: atfcss [html file] {OPTIONS}
-i, --infile Read input from a CSS file. Default: "-" (stdin)
-o, --outfile Write output to a HTML file. Default: "-" (stdout)
-h, --help Show this message.
With npm do:
npm install atfcss
Or to get the command, do:
npm install atfcss -g
MIT