{"id":41067,"library":"express-html-minify","title":"express-html-minify","description":"An Express.js middleware that automatically minifies HTML responses using html-minifier. This package intercepts HTML responses and reduces file size by removing whitespace, comments, and other unnecessary characters. Version 1.0.4 is the latest stable release. It has low release cadence and minimal dependencies, but its approach (intercepting res.end) can conflict with other middleware or streaming responses. Unlike other minifiers, it does not require manual wrapping of res.send or res.render.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"git://github.com/plasmashadow/express-html-minify","tags":["javascript","minify","html"],"install":[{"cmd":"npm install express-html-minify","lang":"bash","label":"npm"},{"cmd":"yarn add express-html-minify","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-html-minify","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core minification engine used to process HTML content.","package":"html-minifier","optional":false}],"imports":[{"note":"This package only supports CommonJS require. ESM imports may fail.","wrong":"import minify from 'express-html-minify';","symbol":"default","correct":"const minify = require('express-html-minify');"},{"note":"The exported value is the middleware function itself, not a factory. Do not call it.","wrong":"app.use(minify());","symbol":"middleware","correct":"app.use(require('express-html-minify'));"},{"note":"There is no named export. The package only exposes the middleware function as default.","wrong":"import { minifyHTML } from 'express-html-minify';","symbol":"minifyHTML","correct":"No named export exists. Only default middleware is exported."}],"quickstart":{"code":"const express = require('express');\nconst minify = require('express-html-minify');\n\nconst app = express();\napp.use(minify);\n\napp.get('/', (req, res) => {\n  res.send('<html>   <head><title>Test</title></head>   <body><h1>Hello</h1></body></html>');\n});\n\napp.listen(3000);","lang":"javascript","description":"Shows basic Express setup with HTML minification middleware. The middleware minifies all HTML responses."},"warnings":[{"fix":"Ensure no other middleware modifies res.end before this middleware. Disable compression for HTML responses if issues occur.","message":"The middleware intercepts res.end and may not work correctly with streaming or compressed responses.","severity":"gotcha","affected_versions":"*"},{"find":"Use res.send with the file content instead, or manually pipe through minification.","message":"Does not minify responses sent via res.sendFile or other methods that bypass res.send.","severity":"gotcha","affected_versions":"*"},{"fix":"Consider using a more actively maintained alternative like 'compression' middleware or custom minification.","message":"No updates since 2017. The underlying html-minifier may have newer versions with different behavior.","severity":"deprecated","affected_versions":"<=1.0.4"}],"env_vars":null,"search_vec":"'1.0.4':35 'approach':51 'automat':9 'cadenc':45 'charact':33 'comment':29 'conflict':55 'depend':48 'express':2 'express-html-minifi':1 'express.js':6 'file':24 'html':3,11,15,20,77 'html-minifi':14 'intercept':19,52 'javascript':75 'latest':38 'low':43 'manual':69 'middlewar':7,58 'minifi':4,10,16,64,76 'minim':47 'packag':18 'reduc':23 'releas':40,44 'remov':27 'requir':68 'res.end':53 'res.render':74 'res.send':72 'respons':12,21,61 'size':25 'stabl':39 'stream':60 'unlik':62 'unnecessari':32 'use':13 'version':34 'whitespac':28 'wrap':70","created_at":"2026-06-04T18:50:36.716509+00:00","updated_at":"2026-06-04T18:50:36.716509+00:00","problems":[{"fix":"Run 'npm install express-html-minify' to install the package.","cause":"Package not installed or typo in require path.","error":"Cannot find module 'express-html-minify'"},{"fix":"Use 'app.use(minify)' without parentheses.","cause":"The exported value is a function, but calling it as middleware factory (minify()) returns undefined.","error":"minify is not a function"},{"fix":"Ensure the minify middleware is placed before any middleware that may modify res.end.","cause":"Another middleware has already consumed the response or res.end is not available.","error":"TypeError: Cannot read property 'end' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/plasmashadow/express-html-minify","github":"git://github.com/plasmashadow/express-html-minify","docs":null,"changelog":null,"pypi":null,"npm":"express-html-minify","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}