{"id":41249,"library":"html-minify-stream","title":"html-minify-stream","description":"Node.js transform stream for minifying HTML using html-minifier. Version 2.0.0 allows streaming HTML documents and passes options directly to html-minifier. Ideal for build pipelines where HTML content is streamed from files or other streams. Does not buffer entire input, enabling low-memory processing of large HTML files. Note that html-minifier is not a pure stream; the stream collects input and processes it on end, but at least it handles backpressure. Primary differentiator from other minification libraries is its streaming interface for Node.js.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/goto-bus-stop/html-minify-stream","tags":["javascript","html","html-minifier","minify","stream"],"install":[{"cmd":"npm install html-minify-stream","lang":"bash","label":"npm"},{"cmd":"yarn add html-minify-stream","lang":"bash","label":"yarn"},{"cmd":"pnpm add html-minify-stream","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core minification engine","package":"html-minifier","optional":false},{"reason":"Stream base (safe polyfill for older Node versions)","package":"readable-stream","optional":false}],"imports":[{"note":"Package uses CommonJS; no named or default ES export. Use require() or use createRequire.","wrong":"import htmlMinifyStream from 'html-minify-stream'","symbol":"default","correct":"const htmlMinifyStream = require('html-minify-stream')"},{"note":"The module exports a function directly, not an object with a method.","wrong":"const { htmlMinifyStream } = require('html-minify-stream')","symbol":"htmlMinifyStream","correct":"const htmlMinifyStream = require('html-minify-stream')"},{"note":"TypeScript with esModuleInterop: use import = require() for CJS modules.","wrong":"import htmlMinifyStream from 'html-minify-stream'","symbol":"type import (TypeScript)","correct":"import htmlMinifyStream = require('html-minify-stream')"}],"quickstart":{"code":"const htmlMinifyStream = require('html-minify-stream')\nconst fs = require('fs')\n\nfs.createReadStream('index.html')\n  .pipe(htmlMinifyStream({\n    collapseWhitespace: true,\n    removeOptionalTags: true\n  }))\n  .pipe(fs.createWriteStream('dist/index.html'))\n","lang":"javascript","description":"Creates a read stream from index.html, pipes through minification, writes to dist/index.html"},"warnings":[{"fix":"Expect the entire output at once; do not consume chunk by chunk.","message":"The stream only emits the complete minified HTML on 'end'. It does not output partial data incrementally.","severity":"gotcha","affected_versions":">=1.0 <3"},{"fix":"Refer to html-minifier documentation for supported options.","message":"Options are passed directly to html-minifier; some options may conflict or cause unexpected behavior.","severity":"gotcha","affected_versions":">=1.0 <3"},{"fix":"Consider switching to a more actively maintained alternative.","message":"The package uses html-minifier v4, which is no longer actively maintained.","severity":"deprecated","affected_versions":">=2.0"}],"env_vars":null,"search_vec":"'2.0.0':16 'allow':17 'backpressur':81 'buffer':45 'build':31 'collect':69 'content':35 'differenti':83 'direct':24 'document':20 'enabl':48 'end':75 'entir':46 'file':39,56 'handl':80 'html':2,10,13,19,27,34,55,60,95,97 'html-minifi':12,26,59,96 'html-minify-stream':1 'ideal':29 'input':47,70 'interfac':91 'javascript':94 'larg':54 'least':78 'librari':87 'low':50 'low-memori':49 'memori':51 'minif':86 'minifi':3,9,14,28,61,98,99 'node.js':5,93 'note':57 'option':23 'pass':22 'pipelin':32 'primari':82 'process':52,72 'pure':65 'stream':4,7,18,37,42,66,68,90,100 'transform':6 'use':11 'version':15","created_at":"2026-06-04T18:51:29.698508+00:00","updated_at":"2026-06-04T18:51:29.698508+00:00","problems":[{"fix":"Use require('html-minify-stream') instead of import.","cause":"Using ES module import syntax with this CommonJS package without proper configuration.","error":"TypeError: htmlMinifyStream is not a function"},{"fix":"Run npm install html-minify-stream in your project directory.","cause":"Package not installed or Node.js cannot resolve it.","error":"Error: Cannot find module 'html-minify-stream'"},{"fix":"Ensure the upstream stream emits strings or Buffers. Use fs.createReadStream with encoding or set encoding on stream.","cause":"Attempting to pipe non-string/Buffer data into the stream.","error":"TypeError: Invalid non-string/buffer chunk"}],"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/goto-bus-stop/html-minify-stream","github":"https://github.com/goto-bus-stop/html-minify-stream","docs":null,"changelog":null,"pypi":null,"npm":"html-minify-stream","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}}