Socket
Socket
Sign inDemoInstall

html-minifier

Package Overview
Dependencies
45
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.3 to 3.1.0

1

cli.js

@@ -135,2 +135,3 @@ #!/usr/bin/env node

sortClassName: 'Sort style classes by frequency',
trimCustomFragments: 'Trim white space around ignoreCustomFragments.',
useShortDoctype: 'Replaces the doctype with the short (HTML5) doctype'

@@ -137,0 +138,0 @@ };

2

package.json
{
"name": "html-minifier",
"description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
"version": "3.0.3",
"version": "3.1.0",
"keywords": [

@@ -6,0 +6,0 @@ "cli",

@@ -25,14 +25,14 @@ # HTMLMinifier

| --------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|
| [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 |

@@ -79,2 +79,3 @@

| `sortClassName` | [Sort style classes by frequency](#sorting-attributes--style-classes) | `false` |
| `trimCustomFragments` | Trim white space around `ignoreCustomFragments`. | `false` |
| `useShortDoctype` | [Replaces the `doctype` with the short (HTML5) doctype](http://perfectionkills.com/experimenting-with-html-minifier/#use_short_doctype) | `false` |

@@ -81,0 +82,0 @@

@@ -861,2 +861,9 @@ 'use strict';

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) {

@@ -866,5 +873,5 @@ 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) {

@@ -876,5 +883,3 @@ uidAttr = uniqueId(value);

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));
};

@@ -884,7 +889,4 @@ }

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);
};

@@ -894,3 +896,3 @@ }

var token = uidAttr + ignoredCustomMarkupChunks.length;
ignoredCustomMarkupChunks.push(match);
ignoredCustomMarkupChunks.push([match, prefix, suffix]);
return '\t' + token + '\t';

@@ -1256,3 +1258,3 @@ });

str = str.replace(uidPattern, function(match, prefix, index, suffix) {
var chunk = ignoredCustomMarkupChunks[+index];
var chunk = ignoredCustomMarkupChunks[+index][0];
if (options.collapseWhitespace) {

@@ -1267,3 +1269,3 @@ if (prefix !== '\t') {

preserveLineBreaks: options.preserveLineBreaks,
conservativeCollapse: true
conservativeCollapse: !options.trimCustomFragments
}, /^\s/.test(chunk), /\s$/.test(chunk));

@@ -1270,0 +1272,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc