Socket
Socket
Sign inDemoInstall

critical

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

critical - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

inline-styles.js

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc