Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

atfcss

crowl13MIT1.0.0

Insert critical CSS into an html file

css, insert, head, above the fold, atf

readme

atfcss

Insert critical css into the first <style> tag of an html file.

example

// 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

methods

var atfcss = require('atfcss')

var stream = atfcss(htmlPath)

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.

usage

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.

install

With npm do:

npm install atfcss

Or to get the command, do:

npm install atfcss -g

license

MIT