critical
Advanced tools
Comparing version 0.1.2 to 0.1.3
23
index.js
@@ -100,1 +100,24 @@ /* | ||
/** | ||
* Generate and inline critical-path CSS | ||
* @param {object} opts Options | ||
* @param {function} cb Callback | ||
* @accepts src, base, width, height, styleTarget, htmlTarget | ||
*/ | ||
exports.generateInline = function (opts, cb) { | ||
opts = opts || {}; | ||
cb = cb || function () {}; | ||
if (!opts.styleTarget && !opts.htmlTarget) { | ||
cb(new Error('Valid style and HTML targets are required.')); | ||
return; | ||
} | ||
var genOpts = opts, inlineOpts = opts; | ||
genOpts.dest = opts.styleTarget; | ||
exports.generate(genOpts, function (err, output) { | ||
if (err) cb(err); | ||
inlineOpts.dest = opts.htmlTarget; | ||
exports.inline(inlineOpts); | ||
}); | ||
} | ||
{ | ||
"name": "critical", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Critical-path CSS generation & inlining", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,2 +20,16 @@ critical | ||
###Generate and inline critical-path CSS | ||
```js | ||
critical.generateInline({ | ||
base: 'dist/', | ||
src: 'index.html', | ||
styleTarget: 'styles/main.css', | ||
htmlTarget: 'index-critical.html', | ||
width: 320, | ||
height: 480, | ||
minify: true | ||
}); | ||
``` | ||
###Generate critical-path CSS | ||
@@ -129,2 +143,12 @@ | ||
####styleTarget | ||
Type: `string` | ||
(generateInline only) Destination for critical-path styles | ||
####htmlTarget | ||
Type: `string` | ||
(generateInline only) Destination for (critical-path CSS) style-inlined HTML | ||
## Why? | ||
@@ -131,0 +155,0 @@ |
8636
146
174