html-minifier 3.5.18 → 3.5.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
  [![Build Status](https://img.shields.io/travis/kangax/html-minifier.svg)](https://travis-ci.org/kangax/html-minifier)
5
5
  [![Dependency Status](https://img.shields.io/david/kangax/html-minifier.svg)](https://david-dm.org/kangax/html-minifier)
6
6
 
7
- [HTMLMinifier](http://kangax.github.io/html-minifier/) is a highly **configurable**, **well-tested**, JavaScript-based HTML minifier.
7
+ [HTMLMinifier](https://kangax.github.io/html-minifier/) is a highly **configurable**, **well-tested**, JavaScript-based HTML minifier.
8
8
 
9
9
  See [corresponding blog post](http://perfectionkills.com/experimenting-with-html-minifier/) for all the gory details of [how it works](http://perfectionkills.com/experimenting-with-html-minifier/#how_it_works), [description of each option](http://perfectionkills.com/experimenting-with-html-minifier/#options), [testing results](http://perfectionkills.com/experimenting-with-html-minifier/#field_testing) and [conclusions](http://perfectionkills.com/experimenting-with-html-minifier/#cost_and_benefits).
10
10
 
11
- [Test suite is available online](http://kangax.github.io/html-minifier/tests/).
11
+ [Test suite is available online](https://kangax.github.io/html-minifier/tests/).
12
12
 
13
13
  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), [Koa middleware wrapper](https://github.com/koajs/html-minifier) and [Express middleware wrapper](https://github.com/melonmanchan/express-minify-html).
14
14
 
@@ -20,19 +20,19 @@ How does HTMLMinifier compare to other solutions — [HTML Minifier from Will Pe
20
20
 
21
21
  | Site | Original size *(KB)* | HTMLMinifier | minimize | Will Peavy | htmlcompressor.com |
22
22
  | ---------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|
23
- | [Google](https://www.google.com/) | 47 | **43** | 47 | 50 | 47 |
24
- | [Twitter](https://twitter.com/) | 139 | **104** | 132 | 152 | 132 |
25
- | [HTMLMinifier](https://github.com/kangax/html-minifier) | 149 | **116** | 124 | 129 | 124 |
26
- | [New York Times](https://www.nytimes.com/) | 225 | **154** | 175 | 170 | 158 |
27
- | [Stack Overflow](https://stackoverflow.com/) | 253 | **196** | 206 | 215 | 204 |
23
+ | [Google](https://www.google.com/) | 46 | **42** | 46 | 48 | 46 |
24
+ | [Twitter](https://twitter.com/) | 143 | **107** | 136 | 157 | 136 |
25
+ | [HTMLMinifier](https://github.com/kangax/html-minifier) | 152 | **119** | 127 | 132 | 127 |
26
+ | [New York Times](https://www.nytimes.com/) | 223 | **152** | 173 | 168 | 156 |
27
+ | [Stack Overflow](https://stackoverflow.com/) | 258 | **201** | 211 | 220 | 208 |
28
28
  | [Bootstrap CSS](https://getbootstrap.com/docs/3.3/css/) | 271 | **260** | 269 | 229 | 269 |
29
- | [BBC](https://www.bbc.co.uk/) | 287 | **231** | 279 | 281 | 272 |
30
- | [Amazon](https://www.amazon.co.uk/) | 438 | **378** | 424 | 436 | n/a |
31
- | [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 484 | **451** | 468 | 484 | 467 |
32
- | [NBC](https://www.nbc.com/) | 692 | **651** | 688 | 691 | n/a |
29
+ | [BBC](https://www.bbc.co.uk/) | 299 | **242** | 290 | 293 | 283 |
30
+ | [Amazon](https://www.amazon.co.uk/) | 398 | **342** | 385 | 397 | n/a |
31
+ | [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 485 | **452** | 470 | 487 | 469 |
32
+ | [NBC](https://www.nbc.com/) | 679 | **639** | 675 | 678 | n/a |
33
33
  | [Eloquent Javascript](https://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
34
- | [ES6 table](https://kangax.github.io/compat-table/es6/) | 5068 | **4320** | 4797 | n/a | n/a |
35
- | [ES6 draft](https://tc39.github.io/ecma262/) | 6051 | **5431** | 5595 | n/a | n/a |
34
+ | [ES6 table](https://kangax.github.io/compat-table/es6/) | 5109 | **4353** | 4834 | n/a | n/a |
35
+ | [ES6 draft](https://tc39.github.io/ecma262/) | 6063 | **5443** | 5607 | n/a | n/a |
36
36
 
37
37
  ## Options Quick Reference
38
38
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "html-minifier",
3
3
  "description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
4
- "version": "3.5.18",
4
+ "version": "3.5.19",
5
5
  "keywords": [
6
6
  "cli",
7
7
  "compress",
@@ -23,11 +23,11 @@
23
23
  "uglifier",
24
24
  "uglify"
25
25
  ],
26
- "homepage": "http://kangax.github.io/html-minifier/",
26
+ "homepage": "https://kangax.github.io/html-minifier/",
27
27
  "author": "Juriy \"kangax\" Zaytsev",
28
28
  "maintainers": [
29
29
  "Alex Lam <alexlamsl@gmail.com>",
30
- "Juriy Zaytsev <kangax@gmail.com> (http://perfectionkills.com)"
30
+ "Juriy Zaytsev <kangax@gmail.com> (http://perfectionkills.com/)"
31
31
  ],
32
32
  "contributors": [
33
33
  "Gilmore Davidson (https://github.com/gilmoreorless)",
@@ -109,7 +109,7 @@ function isEventAttribute(attrName, options) {
109
109
  }
110
110
 
111
111
  function canRemoveAttributeQuotes(value) {
112
- // http://mathiasbynens.be/notes/unquoted-attribute-values
112
+ // https://mathiasbynens.be/notes/unquoted-attribute-values
113
113
  return /^[^ \t\n\f\r"'`=<>]+$/.test(value);
114
114
  }
115
115
 
@@ -374,7 +374,7 @@ function processScript(text, options, currentAttrs) {
374
374
  // Tag omission rules from https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
375
375
  // with the following deviations:
376
376
  // - retain <body> if followed by <noscript>
377
- // - </rb>, </rt>, </rtc>, </rp> & </tfoot> follow http://www.w3.org/TR/html5/syntax.html#optional-tags
377
+ // - </rb>, </rt>, </rtc>, </rp> & </tfoot> follow https://www.w3.org/TR/html5/syntax.html#optional-tags
378
378
  // - retain all tags which are adjacent to non-standard HTML tags
379
379
  var optionalStartTags = createMapFromString('html,head,body,colgroup,tbody');
380
380
  var optionalEndTags = createMapFromString('html,head,body,li,dt,dd,p,rb,rt,rtc,rp,optgroup,option,colgroup,caption,thead,tbody,tfoot,tr,td,th');
@@ -1220,7 +1220,7 @@ function minify(value, options, partialMarkup) {
1220
1220
  buffer.push(text);
1221
1221
  },
1222
1222
  doctype: function(doctype) {
1223
- buffer.push(options.useShortDoctype ? '<!DOCTYPE html>' : collapseWhitespaceAll(doctype));
1223
+ buffer.push(options.useShortDoctype ? '<!doctype html>' : collapseWhitespaceAll(doctype));
1224
1224
  },
1225
1225
  customAttrAssign: options.customAttrAssign,
1226
1226
  customAttrSurround: options.customAttrSurround
@@ -1241,10 +1241,8 @@ function minify(value, options, partialMarkup) {
1241
1241
  squashTrailingWhitespace('br');
1242
1242
  }
1243
1243
 
1244
- var str = joinResultSegments(buffer, options);
1245
-
1246
- if (uidPattern) {
1247
- str = str.replace(uidPattern, function(match, prefix, index, suffix) {
1244
+ return joinResultSegments(buffer, options, uidPattern ? function(str) {
1245
+ return str.replace(uidPattern, function(match, prefix, index, suffix) {
1248
1246
  var chunk = ignoredCustomMarkupChunks[+index][0];
1249
1247
  if (options.collapseWhitespace) {
1250
1248
  if (prefix !== '\t') {
@@ -1260,17 +1258,14 @@ function minify(value, options, partialMarkup) {
1260
1258
  }
1261
1259
  return chunk;
1262
1260
  });
1263
- }
1264
- if (uidIgnore) {
1265
- str = str.replace(new RegExp('<!--' + uidIgnore + '([0-9]+)-->', 'g'), function(match, index) {
1261
+ } : identity, uidIgnore ? function(str) {
1262
+ return str.replace(new RegExp('<!--' + uidIgnore + '([0-9]+)-->', 'g'), function(match, index) {
1266
1263
  return ignoredMarkupChunks[+index];
1267
1264
  });
1268
- }
1269
-
1270
- return str;
1265
+ } : identity);
1271
1266
  }
1272
1267
 
1273
- function joinResultSegments(results, options) {
1268
+ function joinResultSegments(results, options, restoreCustom, restoreIgnore) {
1274
1269
  var str;
1275
1270
  var maxLineLength = options.maxLineLength;
1276
1271
  if (maxLineLength) {
@@ -1279,13 +1274,13 @@ function joinResultSegments(results, options) {
1279
1274
  var len = line.length;
1280
1275
  var end = results[0].indexOf('\n');
1281
1276
  if (end < 0) {
1282
- line += results.shift();
1277
+ line += restoreIgnore(restoreCustom(results.shift()));
1283
1278
  }
1284
1279
  else {
1285
- line += results[0].slice(0, end);
1280
+ line += restoreIgnore(restoreCustom(results[0].slice(0, end)));
1286
1281
  results[0] = results[0].slice(end + 1);
1287
1282
  }
1288
- if (len > 0 && line.length >= maxLineLength) {
1283
+ if (len > 0 && line.length > maxLineLength) {
1289
1284
  lines.push(line.slice(0, len));
1290
1285
  line = line.slice(len);
1291
1286
  }
@@ -1297,11 +1292,10 @@ function joinResultSegments(results, options) {
1297
1292
  if (line) {
1298
1293
  lines.push(line);
1299
1294
  }
1300
-
1301
1295
  str = lines.join('\n');
1302
1296
  }
1303
1297
  else {
1304
- str = results.join('');
1298
+ str = restoreIgnore(restoreCustom(results.join('')));
1305
1299
  }
1306
1300
  return options.collapseWhitespace ? collapseWhitespace(str, options, true, true) : str;
1307
1301
  }
package/src/htmlparser.js CHANGED
@@ -140,7 +140,7 @@ function HTMLParser(html, handler) {
140
140
  }
141
141
  }
142
142
 
143
- // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
143
+ // https://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
144
144
  if (/^<!\[/.test(html)) {
145
145
  var conditionalEnd = html.indexOf(']>');
146
146