Installations
npm install express-minify-html-2
Developer
meszaros-lajos-gyorgy
Developer Guide
Module System
CommonJS
Min. Node Version
>=14.0.0
Typescript Support
No
Node Version
18.9.0
NPM Version
8.19.1
Statistics
12 Stars
115 Commits
1 Forks
2 Watching
1 Branches
1 Contributors
Updated on 22 Jun 2023
Bundle Size
876.27 kB
Minified
256.61 kB
Minified + Gzipped
Languages
JavaScript (66.8%)
HTML (15.71%)
EJS (6.31%)
Handlebars (6.24%)
Pug (4.95%)
Total Downloads
Cumulative downloads
Total Downloads
246,748
Last day
73.2%
194
Compared to previous day
Last week
-16.2%
985
Compared to previous week
Last month
34.6%
5,182
Compared to previous month
Last year
-35.3%
48,785
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
8
express-minify-html-2
Express middleware wrapper around html-minifier-terser
Note that this is a fork of express-minify-html
This fork is made in order to keep the express-minify-html project alive. All credits go to the contributors in the original repo.
Description
This express middleware simply enchances the regular 'render' method of the response object for minifying HTML.
Usage
1npm install --save --production express-minify-html-2 express
1var express = require('express') 2var minifyHTML = require('express-minify-html-2') 3 4var app = express() 5 6app.use( 7 minifyHTML({ 8 override: true, 9 /** 10 * exceptionUrls can also be spelled as exception_url for backwards compatibility 11 */ 12 exceptionUrls: false, 13 htmlMinifier: { 14 removeComments: true, 15 collapseWhitespace: true, 16 collapseBooleanAttributes: true, 17 removeAttributeQuotes: true, 18 removeEmptyAttributes: true, 19 }, 20 }), 21) 22 23app.get('hello', function (req, res, next) { 24 res.render('helloTemplate', { hello: 'world' }, function (err, html) { 25 // The output is minified, huzzah! 26 console.log(html) 27 res.send(html) 28 }) 29})
Set 'override' to false if you don't want to hijack the ordinary res.render function. This adds an additional res.renderMin function to the response object to render minimized HTML.
The 'htmlMinifier' opts are simply passed on to the html-minifier-terser
plugin. For all the available configuration
options, see the original repo!
If no callback is provided, res.render/res.renderMin sends the minified HTML to the client just as the regular express res.render does. Otherwise, the callback is called with the error object and the minified HTML content, as demonstrated above.
the exceptionUrls
(or it's alias exception_url
) optional parameter is a single value, or an array of strings, regexes and functions
that can be used to check whether minifying should be skipped entirely.
1exceptionUrls: [ 2 'url_to_avoid_minify_html', // String. 3 /regex_to_analyze_req_to_avoid_minify/i, // Regex. 4 function (req, res) { 5 // Function. 6 // Code to analyze req and decide if skips or not minify. 7 // Needs to return a boolean value. 8 return true 9 }, 10]
Full examples can naturally be found under the 'examples'-folder of this repository!
Other infos
The code inside minifier.js should be compatible with nodejs 6.0.0,
but since html-minifier-terser
requires "^14.13.1" the package also requires at least nodejs 14.0.0
License
MIT © Matti Jokitulppo
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 1 are checked with a SAST tool
Reason
11 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-3965-hpx2-q597
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
Score
1.7
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to express-minify-html-2
html-minifier-terser
Highly configurable, well-tested, JavaScript-based HTML minifier.
html-minifier
Highly configurable, well-tested, JavaScript-based HTML minifier.
csso
CSS minifier with structural optimisations
express-minify
Automatically minify and cache your javascript and css files.