{"id":41064,"library":"express-hbsmin","title":"Express HBS Minifier","description":"Express middleware for minifying HTML rendered by Handlebars templates. Version 0.1.4, no active release cadence (last update unknown). Wraps html-minifier and overrides res.render to produce minified output. Use with caution: may break spacing of CSS-dependent layouts. Adds optional res.renderMin method if override is false. Supports exception URLs via strings, regexes, or functions. Risk of footguns due to aggressive minification defaults.","status":"active","version":"0.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/wlwl2/express-hbsmin","tags":["javascript","express","hbs","minification","handlebars","minify","middleware","html","minifier"],"install":[{"cmd":"npm install express-hbsmin","lang":"bash","label":"npm"},{"cmd":"yarn add express-hbsmin","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-hbsmin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying HTML minification engine","package":"html-minifier","optional":false},{"reason":"Peer dependency for middleware integration","package":"express","optional":false}],"imports":[{"note":"Package is CommonJS only; ESM import will fail.","wrong":"import minifyHbs from 'express-hbsmin'","symbol":"minifyHbs","correct":"const minifyHbs = require('express-hbsmin')"},{"note":"No default export; direct require returns the middleware function.","wrong":"const minifyHbs = require('express-hbsmin').default","symbol":"minifyHbs","correct":"const minifyHbs = require('express-hbsmin')"},{"note":"The exported value is the middleware factory, not an object with properties.","wrong":"app.use(require('express-hbsmin').middleware({...}))","symbol":"locals","correct":"const app = express(); app.use(require('express-hbsmin')({...}))"}],"quickstart":{"code":"const express = require('express');\nconst minifyHbs = require('express-hbsmin');\n\nconst app = express();\n\napp.use(minifyHbs({\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('/', function (req, res) {\n  res.render('index', { title: 'Hello' });\n});\n\napp.listen(3000);","lang":"javascript","description":"Basic setup with Express and Handlebars to minify HTML output via overridden res.render."},"warnings":[{"fix":"Use exception_url to exclude pages where spacing matters, or customize htmlMinifier options.","message":"Aggressive minification may break CSS spacing due to whitespace collapse.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set override: false and use res.renderMin instead.","message":"Setting override: true hijacks res.render globally; all render calls are minified.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use require() in Node.js. No ESM support planned.","message":"The package is CommonJS-only; ES module imports (import) will not work.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Provide an array of URLs/regexes/functions to skip minification when needed.","message":"exception_url: false disables URL exception checks entirely; unexpected minification on all routes.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.1.4':14 'activ':16 'add':44 'aggress':65 'break':37 'cadenc':18 'caution':35 'css':41 'css-depend':40 'default':67 'depend':42 'due':63 'except':53 'express':1,4,69 'fals':51 'footgun':62 'function':59 'handlebar':11,72 'hbs':2,70 'html':8,24,75 'html-minifi':23 'javascript':68 'last':19 'layout':43 'may':36 'method':47 'middlewar':5,74 'minif':66,71 'minifi':3,7,25,31,73,76 'option':45 'output':32 'overrid':27,49 'produc':30 'regex':57 'releas':17 'render':9 'res.render':28 'res.rendermin':46 'risk':60 'space':38 'string':56 'support':52 'templat':12 'unknown':21 'updat':20 'url':54 'use':33 'version':13 'via':55 'wrap':22","created_at":"2026-06-04T18:50:35.909498+00:00","updated_at":"2026-06-04T18:50:35.909498+00:00","problems":[{"fix":"Use const minifyHbs = require('express-hbsmin');","cause":"Using import instead of require() or incorrect destructuring.","error":"TypeError: minifyHbs is not a function"},{"fix":"Set collapseWhitespace: false or use exception_url to skip minification on affected pages.","cause":"collapseWhitespace: true removes necessary whitespace for CSS-inline-block spacing.","error":"Error: Most minified HTML broke layout (elements overlapping)"},{"fix":"npm install html-minifier express-hbsmin","cause":"Missing peer dependency html-minifier.","error":"NodeError: Cannot find module 'html-minifier'"}],"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/wlwl2/express-hbsmin#readme","github":"https://github.com/wlwl2/express-hbsmin","docs":null,"changelog":null,"pypi":null,"npm":"express-hbsmin","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}}