-
Notifications
You must be signed in to change notification settings - Fork 0
/
critical-css.js
30 lines (28 loc) · 1.01 KB
/
critical-css.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var penthouse = require('penthouse'),
path = require('path'),
fs = require('fs'),
__basedir = './';
penthouse({
url : 'http://192.168.0.155:8888/procraft/',
css : [path.join(__basedir + 'build/styles-min.css')],
// OPTIONAL params
width : 1300, // viewport width
height : 900, // viewport height
forceInclude : [
'.keepMeEvenIfNotSeenInDom',
/^\.regexWorksToo/
],
timeout: 30000, // ms; abort critical css generation after this timeout
strict: false, // set to true to throw on css errors (will run faster if no errors)
maxEmbeddedBase64Length: 1000, // charaters; strip out inline base64 encoded resources larger than this
userAgent: 'Penthouse Critical Path CSS Generator', // specify which user agent string when loading the page
phantomJsOptions: { // see `phantomjs --help` for the list of all available options
'proxy': 'http://proxy.company.com:8080',
'ssl-protocol': 'SSLv3'
}
}, function(err, criticalCss) {
if (err) {
//handle error
}
fs.writeFileSync('critical_css.css', criticalCss);
});