From c4c0bac9cc9a0bb5c7da9646b24b784949352a4f Mon Sep 17 00:00:00 2001 From: Juriy Zaytsev Date: Sat, 24 Oct 2015 20:20:30 +0200 Subject: [PATCH] Add comparison with minimize. Closes #338 --- README.md | 22 +++++++++++----------- benchmark.js | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 93ef6b0..5df1e7b 100644 --- a/README.md +++ b/README.md @@ -11,17 +11,17 @@ See [corresponding blog post](http://perfectionkills.com/experimenting-with-html Also see corresponding [Ruby wrapper](https://github.com/stereobooster/html_minifier), and for Node.js, [Grunt plugin](https://github.com/gruntjs/grunt-contrib-htmlmin), [Gulp module](https://github.com/jonschlinkert/gulp-htmlmin), and [Koa middleware wrapper](https://github.com/koajs/html-minifier). -How does HTMLMinifier compare to [another solution](http://www.willpeavy.com/minifier/) — HTML Minifier from Will Peavy (1st result in [google search for "html minifier"](https://www.google.com/#q=html+minifier)) as well as htmlcompressor.com? +How does HTMLMinifier compare to other solutions — [HTML Minifier from Will Peavy](http://www.willpeavy.com/minifier/) (1st result in [google search for "html minifier"](https://www.google.com/#q=html+minifier)) as well as [htmlcompressor.com](http://htmlcompressor.com) and [minimize](https://github.com/Swaagie/minimize)? -| Site | Original size _(KB)_ | HTMLMinifier _(KB)_ | Will Peavy _(KB)_ | htmlcompressor.com _(KB)_ | -| --------------------------------------------------------------------------- |:-----------:| ----------------:| ------------:| ----------------:| -| [HTMLMinifier page](https://github.com/kangax/html-minifier) | 48.8 | 37.3 | 43.3 | 41.9 | -| [ES6 table](http://kangax.github.io/es5-compat-table/es6/) | 117.9 | 79.9 | 92 | 91.9 | -| [MSN](http://msn.com) | 156.6 | 133 | 145 | 138.3 | -| [Stackoverflow](http://stackoverflow.com) | 200.4 | 159.5 | 168.3 | 163.3 | -| [Amazon](http://amazon.com) | 245.9 | 206.3 | 225 | 218.5 | -| [Wikipedia](http://en.wikipedia.org/wiki/President_of_the_United_States) | 401.4 | 380.6 | 396.3 | n/a | -| [Eloquent Javascript](http://eloquentjavascript.net/print.html) | 869.5 | 830 | 872 | n/a | +| Site | Original size _(KB)_ | HTMLMinifier | minimize | Will Peavy | htmlcompressor.com | +| --------------------------------------------------------------------------- |:-----------:| ----------------:| ----------------:| ------------:| ----------------:| +| [HTMLMinifier page](https://github.com/kangax/html-minifier) | 48.8 | 37.3 | 41.8 | 43.3 | 41.9 | +| [ES6 table](http://kangax.github.io/es5-compat-table/es6/) | 117.9 | 79.9 | 94.1 | 92 | 91.9 | +| [MSN](http://msn.com) | 156.6 | 133 | 137.7 | 145 | 138.3 | +| [Stackoverflow](http://stackoverflow.com) | 200.4 | 159.5 | 165.1 | 168.3 | 163.3 | +| [Amazon](http://amazon.com) | 245.9 | 206.3 | 234.1 | 225 | 218.5 | +| [Wikipedia](http://en.wikipedia.org/wiki/President_of_the_United_States) | 401.4 | 380.6 | 386.6 | 396.3 | n/a | +| [Eloquent Javascript](http://eloquentjavascript.net/print.html) | 869.5 | 830 | 838 | 872 | n/a | @@ -72,7 +72,7 @@ SVG tags are automatically recognized, and when they are minified, both case-sen ### Working with invalid markup -HTMLMinifier **can't work with invalid or partial chunks of markup**. This is because it parses markup into a tree structure, then modifies it (removing anything that was specified for removal, ignoring anything that was specified to be ingored, etc.), then it creates a markup out of that tree and returns it. +HTMLMinifier **can't work with invalid or partial chunks of markup**. This is because it parses markup into a tree structure, then modifies it (removing anything that was specified for removal, ignoring anything that was specified to be ingored, etc.), then it creates a markup out of that tree and returns it. Input markup (e.g. `

foo`) diff --git a/benchmark.js b/benchmark.js index d950f10..687ffad 100644 --- a/benchmark.js +++ b/benchmark.js @@ -6,12 +6,15 @@ var fs = require('fs'), path = require('path'), exec = require('child_process').exec, chalk = require('chalk'), - Table = require('cli-table'); + Table = require('cli-table'), + + Minimize = require('minimize'), + minimize = new Minimize(); var fileNames = [ 'abc', 'amazon', - //'eloquentjavascript', + 'eloquentjavascript', //'es6-draft', 'es6-table', 'google', @@ -96,6 +99,16 @@ function test(fileName, done) { var minifiedSize = stats.size; var minifiedTime = new Date() - startTime; + minimize.parse( + fs.readFileSync(filePath), + function (error, data) { + console.log('minimize', + filePath, + toKb(data.length), + toKb(minifiedSize)); + } + ); + // Gzip the minified output exec('gzip --keep --force --best --stdout ' + minifiedFilePath + ' > ' + gzMinifiedFilePath, function () { // Open and read the size of the minified+gzipped output -- 2.34.1