Socket
Socket
Sign inDemoInstall

html-minifier

Package Overview
Dependencies
11
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.5.19 to 3.5.20

8

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

@@ -58,4 +58,4 @@ "cli",

"camel-case": "3.0.x",
"clean-css": "4.1.x",
"commander": "2.16.x",
"clean-css": "4.2.x",
"commander": "2.17.x",
"he": "1.1.x",

@@ -69,3 +69,3 @@ "param-case": "2.1.x",

"grunt-browserify": "5.3.x",
"grunt-contrib-uglify": "3.3.x",
"grunt-contrib-uglify": "3.4.x",
"gruntify-eslint": "4.0.x",

@@ -72,0 +72,0 @@ "phantomjs-prebuilt": "2.1.x",

@@ -23,15 +23,15 @@ # HTMLMinifier

| ---------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|
| [Google](https://www.google.com/) | 46 | **42** | 46 | 48 | 46 |
| [Twitter](https://twitter.com/) | 143 | **107** | 136 | 157 | 136 |
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 152 | **119** | 127 | 132 | 127 |
| [New York Times](https://www.nytimes.com/) | 223 | **152** | 173 | 168 | 156 |
| [Stack Overflow](https://stackoverflow.com/) | 258 | **201** | 211 | 220 | 208 |
| [Google](https://www.google.com/) | 47 | **43** | 47 | 49 | 47 |
| [Twitter](https://twitter.com/) | 146 | **115** | 138 | 155 | 138 |
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 171 | **128** | 143 | 148 | 142 |
| [New York Times](https://www.nytimes.com/) | 207 | **139** | 158 | 155 | 144 |
| [Stack Overflow](https://stackoverflow.com/) | 256 | **199** | 209 | 217 | 206 |
| [Bootstrap CSS](https://getbootstrap.com/docs/3.3/css/) | 271 | **260** | 269 | 229 | 269 |
| [BBC](https://www.bbc.co.uk/) | 299 | **242** | 290 | 293 | 283 |
| [Amazon](https://www.amazon.co.uk/) | 398 | **342** | 385 | 397 | n/a |
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 485 | **452** | 470 | 487 | 469 |
| [NBC](https://www.nbc.com/) | 679 | **639** | 675 | 678 | n/a |
| [BBC](https://www.bbc.co.uk/) | 294 | **238** | 285 | 289 | 278 |
| [Amazon](https://www.amazon.co.uk/) | 377 | **328** | 368 | 379 | n/a |
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 520 | **484** | 504 | 523 | 503 |
| [NBC](https://www.nbc.com/) | 669 | **633** | 668 | 669 | n/a |
| [Eloquent Javascript](https://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
| [ES6 table](https://kangax.github.io/compat-table/es6/) | 5109 | **4353** | 4834 | n/a | n/a |
| [ES6 draft](https://tc39.github.io/ecma262/) | 6063 | **5443** | 5607 | n/a | n/a |
| [ES6 table](https://kangax.github.io/compat-table/es6/) | 5243 | **4472** | 4963 | n/a | n/a |
| [ES6 draft](https://tc39.github.io/ecma262/) | 6072 | **5449** | 5615 | n/a | n/a |

@@ -38,0 +38,0 @@ ## Options Quick Reference

@@ -338,22 +338,32 @@ 'use strict';

function ignoreCSS(id) {
return '/* clean-css ignore:start */' + id + '/* clean-css ignore:end */';
}
// Wrap CSS declarations for CleanCSS > 3.x
// See https://github.com/jakubpawlowicz/clean-css/issues/418
function wrapInlineCSS(text) {
return '*{' + text + '}';
function wrapCSS(text, type) {
switch (type) {
case 'inline':
return '*{' + text + '}';
case 'media':
return '@media ' + text + '{a{top:0}}';
default:
return text;
}
}
function unwrapInlineCSS(text) {
var matches = text.match(/^\*\{([\s\S]*)\}$/);
function unwrapCSS(text, type) {
var matches;
switch (type) {
case 'inline':
matches = text.match(/^\*\{([\s\S]*)\}$/);
break;
case 'media':
matches = text.match(/^@media ([\s\S]*?)\s*{[\s\S]*}$/);
break;
}
return matches ? matches[1] : text;
}
function wrapMediaQuery(text) {
return '@media ' + text + '{a{top:0}}';
}
function unwrapMediaQuery(text) {
var matches = text.match(/^@media ([\s\S]*?)\s*{[\s\S]*}$/);
return matches ? matches[1] : text;
}
function cleanConditionalComment(comment, options) {

@@ -659,16 +669,3 @@ return options.processConditionalComments ? comment.replace(/^(\[if\s[^\]]+]>)([\s\S]*?)(<!\[endif])$/, function(match, prefix, text, suffix) {

try {
if (type === 'inline') {
text = wrapInlineCSS(text);
}
else if (type === 'media') {
text = wrapMediaQuery(text);
}
text = new CleanCSS(value).minify(text).styles;
if (type === 'inline') {
text = unwrapInlineCSS(text);
}
else if (type === 'media') {
text = unwrapMediaQuery(text);
}
return text;
return unwrapCSS(new CleanCSS(value).minify(wrapCSS(text, type)).styles, type);
}

@@ -864,11 +861,2 @@ catch (err) {

function escapeFragments(fn) {
return function(text, type) {
return fn(text.replace(uidPattern, function(match, prefix, index) {
var chunks = ignoredCustomMarkupChunks[+index];
return chunks[1] + uidAttr + index + chunks[2];
}), type);
};
}
var customFragments = options.ignoreCustomFragments.map(function(re) {

@@ -885,6 +873,34 @@ return re.source;

if (options.minifyCSS) {
options.minifyCSS = escapeFragments(options.minifyCSS);
options.minifyCSS = (function(fn) {
return function(text, type) {
text = text.replace(uidPattern, function(match, prefix, index) {
var chunks = ignoredCustomMarkupChunks[+index];
return chunks[1] + uidAttr + index + chunks[2];
});
var ids = [];
new CleanCSS().minify(wrapCSS(text, type)).warnings.forEach(function(warning) {
var match = uidPattern.exec(warning);
if (match) {
var id = uidAttr + match[2];
text = text.replace(id, ignoreCSS(id));
ids.push(id);
}
});
text = fn(text, type);
ids.forEach(function(id) {
text = text.replace(ignoreCSS(id), id);
});
return text;
};
})(options.minifyCSS);
}
if (options.minifyJS) {
options.minifyJS = escapeFragments(options.minifyJS);
options.minifyJS = (function(fn) {
return function(text, type) {
return fn(text.replace(uidPattern, function(match, prefix, index) {
var chunks = ignoredCustomMarkupChunks[+index];
return chunks[1] + uidAttr + index + chunks[2];
}), type);
};
})(options.minifyJS);
}

@@ -891,0 +907,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc