Skip to content
Browse files

Version 2.1.2

1 parent 65070a7 commit 45ce137486f8a27681f04fecfa8687eca7b1c192 @alexlamsl alexlamsl committed May 2, 2016
Showing with 26 additions and 20 deletions.
  1. +6 −6 README.md
  2. +15 −9 dist/htmlminifier.js
  3. +3 −3 dist/htmlminifier.min.js
  4. +1 −1 index.html
  5. +1 −1 package.json
View
12 README.md
@@ -23,13 +23,13 @@ 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/) | 57 | **54** | 57 | 59 | 57 |
-| [CNN](http://www.cnn.com/) | 105 | **95** | 101 | 103 | 99 |
-| [HTMLMinifier](https://github.com/kangax/html-minifier) | 117 | **75** | 99 | 104 | 100 |
-| [BBC](http://www.bbc.co.uk/) | 151 | **121** | 146 | 150 | 144 |
-| [New York Times](http://www.nytimes.com/) | 175 | **110** | 125 | 129 | 125 |
-| [Stack Overflow](http://stackoverflow.com/) | 242 | **187** | 197 | 206 | 195 |
+| [CNN](http://www.cnn.com/) | 108 | **98** | 105 | 106 | 103 |
+| [HTMLMinifier](https://github.com/kangax/html-minifier) | 117 | **76** | 100 | 104 | 100 |
+| [BBC](http://www.bbc.co.uk/) | 151 | **121** | 145 | 150 | 144 |
+| [New York Times](http://www.nytimes.com/) | 171 | **107** | 122 | 126 | 122 |
+| [Stack Overflow](http://stackoverflow.com/) | 239 | **184** | 193 | 202 | 192 |
| [Bootstrap CSS](http://getbootstrap.com/css/) | 277 | **264** | 274 | 232 | 274 |
-| [Amazon](http://www.amazon.co.uk/) | 410 | **356** | 391 | 403 | n/a |
+| [Amazon](http://www.amazon.co.uk/) | 456 | **400** | 437 | 450 | n/a |
| [NBC](http://www.nbc.com/) | 465 | **446** | 464 | 465 | n/a |
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 475 | **422** | 459 | 474 | n/a |
| [Eloquent Javascript](http://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
View
24 dist/htmlminifier.js
@@ -1,5 +1,5 @@
/*!
- * HTMLMinifier v2.1.1 (http://kangax.github.io/html-minifier/)
+ * HTMLMinifier v2.1.2 (http://kangax.github.io/html-minifier/)
* Copyright 2010-2016 Juriy "kangax" Zaytsev
* Licensed under the MIT license
*/
@@ -32245,7 +32245,7 @@ function collapseWhitespace(str, options, trimLeft, trimRight, collapseAll) {
str = str.replace(/^[\t ]*[\n\r][\t\n\r ]*/, function() {
lineBreakBefore = '\n';
return '';
- }).replace(/[\t\n\r ]*[\n\r][\t ]*$/, function() {
+ }).replace(/[\t ]*[\n\r][\t\n\r ]*$/, function() {
lineBreakAfter = '\n';
return '';
});
@@ -33014,7 +33014,9 @@ function minify(value, options, partialMarkup) {
options = options || {};
var optionsStack = [];
processOptions(options);
- value = options.collapseWhitespace ? trimWhitespace(value) : value;
+ if (options.collapseWhitespace) {
+ value = collapseWhitespace(value, options, true, true);
+ }
var buffer = [],
charsPrevTag,
@@ -33295,7 +33297,7 @@ function minify(value, options, partialMarkup) {
if (!prevComment) {
prevTag = charsPrevTag;
}
- if (buffer.length > 1 && (!prevComment || / $/.test(currentChars))) {
+ if (buffer.length > 1 && (!prevComment || !options.conservativeCollapse && / $/.test(currentChars))) {
var charsIndex = buffer.length - 2;
buffer[charsIndex] = buffer[charsIndex].replace(/\s+$/, function(trailingSpaces) {
text = trailingSpaces + text;
@@ -33314,13 +33316,18 @@ function minify(value, options, partialMarkup) {
text = collapseWhitespace(text, options, /(?:^|\s)$/.test(currentChars));
}
}
- text = prevTag || nextTag ? collapseWhitespaceSmart(text, prevTag, nextTag, options) : trimWhitespace(text);
+ if (prevTag || nextTag) {
+ text = collapseWhitespaceSmart(text, prevTag, nextTag, options);
+ }
+ else {
+ text = collapseWhitespace(text, options, true, true);
+ }
if (!text && /\s$/.test(currentChars) && prevTag && prevTag.charAt(0) === '/') {
trimTrailingWhitespace(buffer.length - 1, nextTag);
}
}
- if (!stackNoCollapseWhitespace.length) {
- text = prevTag && nextTag || nextTag === 'html' ? text : collapseWhitespaceAll(text);
+ if (!stackNoCollapseWhitespace.length && nextTag !== 'html' && !(prevTag && nextTag)) {
+ text = collapseWhitespace(text, options, false, false, true);
}
}
if (options.processScripts && specialContentTags(currentTag)) {
@@ -33458,8 +33465,7 @@ function joinResultSegments(results, options) {
else {
str = results.join('');
}
-
- return options.collapseWhitespace ? trimWhitespace(str) : str;
+ return options.collapseWhitespace ? collapseWhitespace(str, options, true, true) : str;
}
exports.minify = function(value, options) {
View
6 dist/htmlminifier.min.js
3 additions, 3 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 index.html
@@ -8,7 +8,7 @@
<body>
<div id="outer-wrapper">
<div id="wrapper">
- <h1>HTML Minifier <span>(v2.1.1)</span></h1>
+ <h1>HTML Minifier <span>(v2.1.2)</span></h1>
<textarea rows="8" cols="40" id="input"></textarea>
<div class="minify-button">
<button type="button" id="minify-btn">Minify</button>
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "html-minifier",
"description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
- "version": "2.1.1",
+ "version": "2.1.2",
"keywords": [
"cli",
"compress",

0 comments on commit 45ce137

Please sign in to comment.
Something went wrong with that request. Please try again.