Comparing version 0.1.0 to 0.1.1
52
index.js
@@ -41,27 +41,29 @@ /* | ||
var url = opts.base + opts.src; | ||
// Oust extracts a list of your stylesheets | ||
oust({ src: url }, function (hrefs){ | ||
// Penthouse then determines your critical | ||
// path CSS using these as input. | ||
penthouse({ | ||
url : url, | ||
css : opts.base + hrefs[0], | ||
// What viewports do you care about? | ||
width : opts.width, // viewport width | ||
height : opts.height // viewport height | ||
}, function (err, criticalCSS) { | ||
if(opts.minify === true){ | ||
var minimized = new CleanCSS().minify(criticalCSS); | ||
criticalCSS = minimized; | ||
} | ||
if(opts.dest){ | ||
// Write critical-path CSS | ||
fs.writeFile(path.join(__dirname, opts.base + opts.dest), criticalCSS, function (err){ | ||
cb(err, criticalCSS) | ||
}); | ||
} else { | ||
cb(err, criticalCSS); | ||
} | ||
}); | ||
}); | ||
fs.readFile(url, function (err, html){ | ||
if (err) throw err; | ||
// Oust extracts a list of your stylesheets | ||
var hrefs = oust(html, 'stylesheets'); | ||
// Penthouse then determines your critical | ||
// path CSS using these as input. | ||
penthouse({ | ||
url : url, | ||
css : opts.base + hrefs[0], | ||
// What viewports do you care about? | ||
width : opts.width, // viewport width | ||
height : opts.height // viewport height | ||
}, function (err, criticalCSS) { | ||
if(opts.minify === true){ | ||
var minimized = new CleanCSS().minify(criticalCSS); | ||
criticalCSS = minimized; | ||
} | ||
if(opts.dest){ | ||
// Write critical-path CSS | ||
fs.writeFile(path.join(__dirname, opts.base + opts.dest), criticalCSS, function (err){ | ||
cb(err, criticalCSS) | ||
}); | ||
} else { | ||
cb(err, criticalCSS); | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -68,0 +70,0 @@ |
{ | ||
"name": "critical", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Critical-path CSS generation & inlining", | ||
@@ -10,3 +10,4 @@ "main": "index.js", | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"inline-styles.js" | ||
], | ||
@@ -25,3 +26,3 @@ "keywords": [ | ||
"dependencies": { | ||
"oust": "0.0.1", | ||
"oust": "0.1.1", | ||
"penthouse": "^0.2.1", | ||
@@ -28,0 +29,0 @@ "clean-css": "~2.2.4", |
@@ -16,3 +16,3 @@ critical | ||
``` | ||
```sh | ||
var critical = require('critical'); | ||
@@ -25,3 +25,3 @@ ``` | ||
``` | ||
```js | ||
critical.generate({ | ||
@@ -38,3 +38,3 @@ base: 'test/', | ||
``` | ||
```js | ||
critical.generate({ | ||
@@ -52,3 +52,3 @@ base: 'test/', | ||
``` | ||
```js | ||
critical.generate({ | ||
@@ -69,3 +69,3 @@ base: 'test/', | ||
``` | ||
```js | ||
critical.inline({ | ||
@@ -80,3 +80,3 @@ base: 'test/', | ||
``` | ||
```js | ||
critical.inline({ | ||
@@ -92,3 +92,3 @@ base: 'test/', | ||
``` | ||
```js | ||
critical.inline({ | ||
@@ -95,0 +95,0 @@ base: 'test/', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7485
4
125
3
+ Addedminimist@0.1.0(transitive)
+ Addedoust@0.1.1(transitive)
- Removedoust@0.0.1(transitive)
Updatedoust@0.1.1