mirror of
https://github.com/danog/inline-critical.git
synced 2024-11-26 20:14:41 +01:00
some cleanup
This commit is contained in:
parent
95606c5cda
commit
be3889c1cf
15
index.js
15
index.js
@ -19,21 +19,28 @@ var cheerio = require('cheerio');
|
||||
var CleanCSS = require('clean-css');
|
||||
var slash = require('slash');
|
||||
var normalizeNewline = require('normalize-newline');
|
||||
|
||||
// get loadCSS
|
||||
var loadCSS = read(path.join(__dirname,'vendor','loadCSS.js'));
|
||||
loadCSS = UglifyJS.minify(loadCSS, {fromString: true}).code;
|
||||
|
||||
/**
|
||||
* Fixup slashes in file paths for windows
|
||||
* @param {string} str
|
||||
* @return {string}
|
||||
*/
|
||||
function normalizePath(str) {
|
||||
return process.platform === 'win32' ? slash(str) : str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read file *
|
||||
* @param {string} file
|
||||
* @returns {string}
|
||||
*/
|
||||
function read (file) {
|
||||
return fs.readFileSync(file, 'utf8');
|
||||
}
|
||||
|
||||
var loadCSS = read(path.join(__dirname,'vendor','loadCSS.js'));
|
||||
loadCSS = UglifyJS.minify(loadCSS, {fromString: true}).code;
|
||||
|
||||
|
||||
|
||||
@ -82,7 +89,7 @@ module.exports = function(html, styles, options) {
|
||||
noscript.append('\n');
|
||||
});
|
||||
|
||||
// build js block to load blocking stylesheets
|
||||
// build js block to load blocking stylesheets and insert it right before
|
||||
$(noscript).before('<script>\n' +
|
||||
'(function(u){' +
|
||||
loadCSS +
|
||||
|
Loading…
Reference in New Issue
Block a user