{"id":41069,"library":"express-minify-html-terser","title":"express-minify-html-terser","description":"Express middleware that wraps html-minifier-terser to minify HTML responses. Version 1.0.2, no recent updates, stable. Replaces deprecated express-minify-html with up-to-date html-minifier-terser. Intercepts res.render() or adds res.renderMin() for minification. Supports configuration of html-minifier options and exception URLs.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/jonamat/express-minify-html-terser","tags":["javascript","express","html","minifier","middleware","minify","typescript"],"install":[{"cmd":"npm install express-minify-html-terser","lang":"bash","label":"npm"},{"cmd":"yarn add express-minify-html-terser","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-minify-html-terser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core HTML minification library","package":"html-minifier-terser","optional":false}],"imports":[{"note":"Use default import (ESM) or require. Typings ship types.","wrong":"const minifyHTML = require('express-minify-html-terser')","symbol":"minifyHTML","correct":"import minifyHTML from 'express-minify-html-terser'"},{"note":"CommonJS require returns the function directly, not as a default export.","wrong":"const minifyHTML = require('express-minify-html-terser').default","symbol":"minifyHTML","correct":"const minifyHTML = require('express-minify-html-terser')"},{"note":"Optional type export; use for TypeScript.","wrong":null,"symbol":"MinifyHTMLOptions","correct":"import { MinifyHTMLOptions } from 'express-minify-html-terser'"}],"quickstart":{"code":"import express from 'express';\nimport minifyHTML from 'express-minify-html-terser';\n\nconst app = express();\n\napp.use(minifyHTML({\n    override: true,\n    exception_url: false,\n    htmlMinifier: {\n        removeComments: true,\n        collapseWhitespace: true,\n        collapseBooleanAttributes: true,\n        removeAttributeQuotes: true,\n        removeEmptyAttributes: true,\n        minifyJS: true\n    }\n}));\n\napp.get('/', (req, res) => {\n    res.render('index', { title: 'Hello' });\n});\n\napp.listen(3000);","lang":"typescript","description":"Shows basic setup with minification options and exception URL disabled."},"warnings":[{"fix":"Set exception_url to an array of regex/strings/functions to skip minification for certain routes.","message":"Unless exception_url is set, all HTML responses are minified. Ensure exception_url includes non-HTML routes.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Switch to express-minify-html-terser for support.","message":"This package is a fork replacing deprecated html-minifier with html-minifier-terser. Use this instead of express-minify-html.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Test thoroughly; refer to html-minifier-terser documentation for valid options.","message":"The htmlMinifier options are passed directly to html-minifier-terser. Some options may conflict or cause errors when minifying inline JS or CSS.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.0.2':19 'add':42 'configur':47 'date':34 'deprec':25 'except':54 'express':2,6,27,57 'express-minify-html':26 'express-minify-html-ters':1 'html':4,11,16,29,36,50,58 'html-minifi':49 'html-minifier-ters':10,35 'intercept':39 'javascript':56 'middlewar':7,60 'minif':45 'minifi':3,12,15,28,37,51,59,61 'option':52 'recent':21 'replac':24 'res.render':40 'res.rendermin':43 'respons':17 'stabl':23 'support':46 'terser':5,13,38 'typescript':62 'up-to-d':31 'updat':22 'url':55 'version':18 'wrap':9","created_at":"2026-06-04T18:50:37.712705+00:00","updated_at":"2026-06-04T18:50:37.712705+00:00","problems":[{"fix":"Use const minifyHTML = require('express-minify-html-terser'); (without .default)","cause":"Using default import when CommonJS require returns the function directly without .default.","error":"TypeError: minifyHTML is not a function"},{"fix":"Run: npm install html-minifier-terser","cause":"Missing peer dependency html-minifier-terser.","error":"Cannot find module 'html-minifier-terser'"},{"fix":"Pass an object with at least an htmlMinifier property: minifyHTML({ htmlMinifier: { removeComments: true } })","cause":"Missing or invalid options object passed to middleware.","error":"Error: Minify HTML options must be an object"}],"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/jonamat/express-minify-html-terser#readme","github":"https://github.com/jonamat/express-minify-html-terser","docs":null,"changelog":null,"pypi":null,"npm":"express-minify-html-terser","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}}