Socket
Socket
Sign inDemoInstall

html-minifier

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-minifier - npm Package Compare versions

Comparing version 2.1.7 to 3.0.0

49

cli.js

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

decodeEntities: 'Use direct Unicode characters whenever possible',
html5: 'Parse input according to HTML5 specifications',

@@ -191,2 +192,3 @@ ignoreCustomComments: ['Array of regex\'es that allow to ignore certain comments, when matched', parseJSONRegExpArray],

program.option('--output-dir <dir>', 'Specify an output directory');
program.option('--file-ext <text>', 'Specify an extension to be read, ex: html');
var content;

@@ -211,3 +213,3 @@ program.arguments('[files...]').action(function(files) {

function processDirectory(inputDir, outputDir) {
function processDirectory(inputDir, outputDir, fileExt) {
fs.readdir(inputDir, function(err, files) {

@@ -224,24 +226,26 @@ if (err) {

var outputFile = path.join(outputDir, file);
fs.readFile(inputFile, { encoding: 'utf8' }, function(err, data) {
if (!err) {
var minified;
try {
minified = minify(data, createOptions());
if (fileExt ? path.extname(file) === '.' + fileExt : true) {
fs.readFile(inputFile, { encoding: 'utf8' }, function(err, data) {
if (!err) {
var minified;
try {
minified = minify(data, createOptions());
}
catch (e) {
fatal('Minification error on ' + inputFile + '\n' + e.message);
}
fs.writeFile(outputFile, minified, { encoding: 'utf8' }, function(err) {
if (err) {
fatal('Cannot write ' + outputFile + '\n' + err.message);
}
});
}
catch (e) {
fatal('Minification error on ' + inputFile + '\n' + e.message);
else if (err.code === 'EISDIR') {
processDirectory(inputFile, outputFile, fileExt);
}
fs.writeFile(outputFile, minified, { encoding: 'utf8' }, function(err) {
if (err) {
fatal('Cannot write ' + outputFile + '\n' + err.message);
}
});
}
else if (err.code === 'EISDIR') {
processDirectory(inputFile, outputFile);
}
else {
fatal('Cannot read ' + inputFile + '\n' + err.message);
}
});
else {
fatal('Cannot read ' + inputFile + '\n' + err.message);
}
});
}
});

@@ -265,2 +269,3 @@ });

var outputDir = program.outputDir;
var fileExt = program.fileExt;
if (inputDir || outputDir) {

@@ -273,3 +278,3 @@ if (!inputDir) {

}
processDirectory(inputDir, outputDir);
processDirectory(inputDir, outputDir, fileExt);
}

@@ -276,0 +281,0 @@ // Minifying one or more files specified on the CMD line

{
"name": "html-minifier",
"description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
"version": "2.1.7",
"version": "3.0.0",
"keywords": [

@@ -50,3 +50,3 @@ "cli",

"engines": {
"node": ">=0.10.0"
"node": ">=4"
},

@@ -64,3 +64,3 @@ "scripts": {

"relateurl": "0.2.x",
"uglify-js": "2.6.x"
"uglify-js": "2.7.x"
},

@@ -67,0 +67,0 @@ "devDependencies": {

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

| --------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|
| [Google](https://www.google.com/) | 48 | **46** | 48 | 50 | 48 |
| [CNN](http://www.cnn.com/) | 115 | **105** | 111 | 113 | 109 |
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 117 | **79** | 99 | 103 | 99 |
| [BBC](http://www.bbc.co.uk/) | 179 | **147** | 172 | 177 | 168 |
| [New York Times](http://www.nytimes.com/) | 186 | **127** | 136 | 140 | 134 |
| [Stack Overflow](http://stackoverflow.com/) | 240 | **186** | 195 | 204 | 193 |
| [Google](https://www.google.com/) | 44 | **43** | 45 | 46 | 45 |
| [CNN](http://www.cnn.com/) | 115 | **104** | 111 | 112 | 108 |
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 118 | **80** | 100 | 105 | 101 |
| [BBC](http://www.bbc.co.uk/) | 180 | **147** | 173 | 178 | 169 |
| [New York Times](http://www.nytimes.com/) | 188 | **128** | 138 | 142 | 135 |
| [Stack Overflow](http://stackoverflow.com/) | 237 | **183** | 192 | 200 | 190 |
| [Bootstrap CSS](http://getbootstrap.com/css/) | 277 | **264** | 274 | 232 | 274 |
| [Amazon](http://www.amazon.co.uk/) | 431 | **377** | 412 | 424 | n/a |
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 481 | **437** | 464 | 479 | n/a |
| [NBC](http://www.nbc.com/) | 508 | **486** | 506 | 508 | n/a |
| [Amazon](http://www.amazon.co.uk/) | 429 | **374** | 409 | 421 | n/a |
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 481 | **437** | 465 | 480 | n/a |
| [NBC](http://www.nbc.com/) | 499 | **477** | 497 | 499 | 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/) | 3884 | **3272** | 3664 | 3839 | n/a |
| [ES6 table](http://kangax.github.io/compat-table/es6/) | 3884 | **3272** | 3665 | 3839 | n/a |
| [ES6 draft](https://tc39.github.io/ecma262/) | 4797 | **4247** | 4377 | 4500 | n/a |

@@ -39,0 +39,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc