hexo-filter-optimize
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,6 +6,6 @@ // the main filter function | ||
var Jsdom = require('jsdom').JSDOM; | ||
var streamToArray = require('stream-to-array'); | ||
var streamToArrayAsync = Promise.promisify(streamToArray); | ||
var streamRead = require('./stream'); | ||
var route = this.route; | ||
var logger = this.log || console; | ||
var root = this.config.root; | ||
@@ -53,5 +53,8 @@ var config = this.config.filter_optimize; | ||
var stream = route.get(path); | ||
return streamToArrayAsync(stream) | ||
.then(function (arr) { | ||
inlineCssText += arr.join(''); | ||
return streamRead(stream) | ||
.then(function (data) { | ||
inlineCssText += data; | ||
}) | ||
.catch(function (err) { | ||
logger.log('Errors when get the inline css: ', path, err); | ||
}); | ||
@@ -69,4 +72,3 @@ }); | ||
var stream = route.get(path); | ||
return streamToArrayAsync(stream) | ||
.then(function (arr) { return arr.join(''); }) | ||
return streamRead(stream) | ||
.then(function (str) { | ||
@@ -136,2 +138,5 @@ // load jsdom from the html string | ||
// record it | ||
if (scriptText.length > 0) { | ||
scriptText += ';\n'; | ||
} | ||
scriptText += el.textContent; | ||
@@ -205,7 +210,9 @@ el.remove(); | ||
var stream = route.get(path); | ||
return streamToArrayAsync(stream) | ||
.then(function (arr) { return arr.join(''); }) | ||
return streamRead(stream) | ||
.then(function (str) { | ||
// console.log('bundle: ' + path); | ||
content += ';\n' + str; | ||
if (content.length > 0) { | ||
content += ';\n'; | ||
} | ||
content += str; | ||
}); | ||
@@ -212,0 +219,0 @@ }; |
{ | ||
"name": "hexo-filter-optimize", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A hexo plugin that optimize the pages loading speed.", | ||
@@ -28,4 +28,3 @@ "main": "index.js", | ||
"jsdom": "^11.6.0", | ||
"minimatch": "^3.0.4", | ||
"stream-to-array": "^2.3.0" | ||
"minimatch": "^3.0.4" | ||
}, | ||
@@ -32,0 +31,0 @@ "devDependencies": { |
@@ -33,8 +33,8 @@ # hexo-filter-optimize | ||
# - default is ['css/main.css'] | ||
inline: | ||
exclude: | ||
inlines: | ||
excludes: | ||
js: | ||
# bundle loaded js file into the one | ||
bundle: true | ||
exclude: | ||
excludes: | ||
``` | ||
@@ -51,2 +51,2 @@ | ||
![Comparison](https://user-images.githubusercontent.com/980449/35233293-a8229c72-ffd8-11e7-8a23-3b8bc10d40c3.png) | ||
![Comparison](https://user-images.githubusercontent.com/980449/35233293-a8229c72-ffd8-11e7-8a23-3b8bc10d40c3.png) |
12185
3
8
250
51
- Removedstream-to-array@^2.3.0
- Removedany-promise@1.3.0(transitive)
- Removedstream-to-array@2.3.0(transitive)