
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
express-minify-html-terser
Advanced tools
Express middleware wrapper around HTML minifier
This is a fork of express-minify-html to wrap the newer html-minifier-terser instead of html-minifier.
This express middleware simply enchances the regular 'render' method of the response object for minifying HTML.
npm i express-minify-html-terser
var express = require('express');
var minifyHTML = require('express-minify-html-terser');
var app = express();
app.use(minifyHTML({
override: true,
exception_url: false,
htmlMinifier: {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeEmptyAttributes: true,
minifyJS: true
}
}));
app.get('hello', function (req, res, next) {
res.render('helloTemplate', { hello : 'world'}, function(err, html) {
// The output is minified, huzzah!
console.log(html);
res.send(html);
})
});
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 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 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.
exception_url: [
'url_to_avoid_minify_html', // String.
/regex_to_analyze_req_to_avoid_minify/i, // Regex.
function(req, res) { // Function.
// Code to analyze req and decide if skips or not minify.
// Needs to return a boolean value.
return true
}
]
Full examples can naturally be found under the 'examples'-folder of this repository!
MIT © Matti Jokitulppo
FAQs
Express middleware around HTML minifier
The npm package express-minify-html-terser receives a total of 37 weekly downloads. As such, express-minify-html-terser popularity was classified as not popular.
We found that express-minify-html-terser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.