Skip to content

Commit

Permalink
Version 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed May 2, 2016
1 parent 65070a7 commit 45ce137
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
24 changes: 15 additions & 9 deletions dist/htmlminifier.js
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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 '';
});
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions dist/htmlminifier.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 45ce137

Please sign in to comment.