Permalink
Browse files

Version 3.1.0

  • Loading branch information...
1 parent b7068fb commit 969d21a0a86696d0bb148e3c6bd572bddd9049c5 @alexlamsl alexlamsl committed Sep 26, 2016
Showing with 50 additions and 42 deletions.
  1. +9 −9 README.md
  2. +34 −27 dist/htmlminifier.js
  3. +4 −4 dist/htmlminifier.min.js
  4. +1 −1 index.html
  5. +1 −1 package.json
  6. +1 −0 sample-cli-config-file.conf
View
@@ -22,18 +22,18 @@ How does HTMLMinifier compare to other solutions — [HTML Minifier from Will Pe
| Site | Original size *(KB)* | HTMLMinifier | minimize | Will Peavy | htmlcompressor.com |
| --------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|
-| [Google](https://www.google.com/) | 44 | **43** | 45 | 46 | 45 |
-| [HTMLMinifier](https://github.com/kangax/html-minifier) | 118 | **80** | 100 | 105 | 101 |
-| [CNN](http://www.cnn.com/) | 142 | **130** | 138 | 139 | 134 |
-| [Amazon](http://www.amazon.co.uk/) | 165 | **131** | 157 | 160 | n/a |
+| [Google](https://www.google.com/) | 44 | **42** | 44 | 46 | 44 |
+| [HTMLMinifier](https://github.com/kangax/html-minifier) | 120 | **81** | 102 | 106 | 102 |
+| [CNN](http://www.cnn.com/) | 145 | **133** | 141 | 142 | 137 |
| [BBC](http://www.bbc.co.uk/) | 168 | **137** | 161 | 165 | 157 |
-| [New York Times](http://www.nytimes.com/) | 189 | **126** | 139 | 142 | 134 |
-| [Stack Overflow](http://stackoverflow.com/) | 241 | **186** | 196 | 204 | 194 |
+| [New York Times](http://www.nytimes.com/) | 188 | **126** | 139 | 140 | 133 |
+| [Stack Overflow](http://stackoverflow.com/) | 238 | **183** | 193 | 200 | 190 |
| [Bootstrap CSS](http://getbootstrap.com/css/) | 276 | **264** | 273 | 231 | 274 |
-| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 482 | **439** | 467 | 481 | n/a |
-| [NBC](http://www.nbc.com/) | 538 | **516** | 536 | 538 | n/a |
+| [Amazon](http://www.amazon.co.uk/) | 369 | **313** | 352 | 360 | n/a |
+| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 490 | **447** | 474 | 488 | n/a |
+| [NBC](http://www.nbc.com/) | 541 | **519** | 539 | 541 | n/a |
| [Eloquent Javascript](http://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
-| [ES6 table](http://kangax.github.io/compat-table/es6/) | 3912 | **3297** | 3692 | 3866 | n/a |
+| [ES6 table](http://kangax.github.io/compat-table/es6/) | 4087 | **3446** | 3859 | 4039 | n/a |
| [ES6 draft](https://tc39.github.io/ecma262/) | 4869 | **4326** | 4455 | 4579 | n/a |
## Options Quick Reference
View
@@ -1,5 +1,5 @@
/*!
- * HTMLMinifier v3.0.3 (http://kangax.github.io/html-minifier/)
+ * HTMLMinifier v3.1.0 (http://kangax.github.io/html-minifier/)
* Copyright 2010-2016 Juriy "kangax" Zaytsev
* Licensed under the MIT license
*/
@@ -312,30 +312,25 @@ module.exports = amdefine;
},{"_process":81,"path":79}],2:[function(require,module,exports){
'use strict'
+exports.byteLength = byteLength
exports.toByteArray = toByteArray
exports.fromByteArray = fromByteArray
var lookup = []
var revLookup = []
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
-function init () {
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
- for (var i = 0, len = code.length; i < len; ++i) {
- lookup[i] = code[i]
- revLookup[code.charCodeAt(i)] = i
- }
-
- revLookup['-'.charCodeAt(0)] = 62
- revLookup['_'.charCodeAt(0)] = 63
+var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
+for (var i = 0, len = code.length; i < len; ++i) {
+ lookup[i] = code[i]
+ revLookup[code.charCodeAt(i)] = i
}
-init()
+revLookup['-'.charCodeAt(0)] = 62
+revLookup['_'.charCodeAt(0)] = 63
-function toByteArray (b64) {
- var i, j, l, tmp, placeHolders, arr
+function placeHoldersCount (b64) {
var len = b64.length
-
if (len % 4 > 0) {
throw new Error('Invalid string. Length must be a multiple of 4')
}
@@ -345,9 +340,19 @@ function toByteArray (b64) {
// represent one byte
// if there is only one, then the three characters before it represent 2 bytes
// this is just a cheap hack to not do indexOf twice
- placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
+ return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
+}
+function byteLength (b64) {
// base64 is 4/3 + up to two characters of the original data
+ return b64.length * 3 / 4 - placeHoldersCount(b64)
+}
+
+function toByteArray (b64) {
+ var i, j, l, tmp, placeHolders, arr
+ var len = b64.length
+ placeHolders = placeHoldersCount(b64)
+
arr = new Arr(len * 3 / 4 - placeHolders)
// if there are placeholders, only get up to the last complete 4 chars
@@ -33986,36 +33991,38 @@ function minify(value, options, partialMarkup) {
return token;
});
+ function escapeFragments(text) {
+ return text.replace(uidPattern, function(match, prefix, index) {
+ var chunks = ignoredCustomMarkupChunks[+index];
+ return chunks[1] + uidAttr + index + chunks[2];
+ });
+ }
+
var customFragments = options.ignoreCustomFragments.map(function(re) {
return re.source;
});
if (customFragments.length) {
- var reCustomIgnore = new RegExp('\\s*(?:' + customFragments.join('|') + ')+\\s*', 'g');
+ var reCustomIgnore = new RegExp('(\\s*)(?:' + customFragments.join('|') + ')+(\\s*)', 'g');
// temporarily replace custom ignored fragments with unique attributes
- value = value.replace(reCustomIgnore, function(match) {
+ value = value.replace(reCustomIgnore, function(match, prefix, suffix) {
if (!uidAttr) {
uidAttr = uniqueId(value);
uidPattern = new RegExp('(\\s*)' + uidAttr + '([0-9]+)(\\s*)', 'g');
var minifyCSS = options.minifyCSS;
if (minifyCSS) {
options.minifyCSS = function(text) {
- return minifyCSS(text).replace(uidPattern, function(match, prefix, index, suffix) {
- return (prefix && '\t') + uidAttr + index + (suffix && '\t');
- });
+ return minifyCSS(escapeFragments(text));
};
}
var minifyJS = options.minifyJS;
if (minifyJS) {
- var pattern = new RegExp('(\\\\t|)' + uidAttr + '([0-9]+)(\\\\t|)', 'g');
options.minifyJS = function(text, inline) {
- return minifyJS(text, inline).replace(pattern, function(match, prefix, index, suffix) {
- return (prefix && '\t') + uidAttr + index + (suffix && '\t');
- });
+ return minifyJS(escapeFragments(text), inline);
};
}
}
var token = uidAttr + ignoredCustomMarkupChunks.length;
- ignoredCustomMarkupChunks.push(match);
+ ignoredCustomMarkupChunks.push([match, prefix, suffix]);
return '\t' + token + '\t';
});
}
@@ -34376,7 +34383,7 @@ function minify(value, options, partialMarkup) {
if (uidPattern) {
str = str.replace(uidPattern, function(match, prefix, index, suffix) {
- var chunk = ignoredCustomMarkupChunks[+index];
+ var chunk = ignoredCustomMarkupChunks[+index][0];
if (options.collapseWhitespace) {
if (prefix !== '\t') {
chunk = prefix + chunk;
@@ -34386,7 +34393,7 @@ function minify(value, options, partialMarkup) {
}
return collapseWhitespace(chunk, {
preserveLineBreaks: options.preserveLineBreaks,
- conservativeCollapse: true
+ conservativeCollapse: !options.trimCustomFragments
}, /^\s/.test(chunk), /\s$/.test(chunk));
}
return chunk;
Oops, something went wrong.
View
@@ -9,7 +9,7 @@
<body>
<div id="outer-wrapper">
<div id="wrapper">
- <h1>HTML Minifier <span>(v3.0.3)</span></h1>
+ <h1>HTML Minifier <span>(v3.1.0)</span></h1>
<textarea rows="8" cols="40" id="input"></textarea>
<div class="minify-button">
<button type="button" id="minify-btn">Minify</button>
View
@@ -1,7 +1,7 @@
{
"name": "html-minifier",
"description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
- "version": "3.0.3",
+ "version": "3.1.0",
"keywords": [
"cli",
"compress",
@@ -34,5 +34,6 @@
"removeTagWhitespace": true,
"sortAttributes": true,
"sortClassName": true,
+ "trimCustomFragments": true,
"useShortDoctype": true
}

0 comments on commit 969d21a

Please sign in to comment.