A Metalsmith plugin for optimizing and minifying HTML files. Current stable version: 0.10.0. Release cadence: irregular, maintained by GitHub user wernerglinka. Key differentiators: single-pass tokenizer for high performance (300x improvement over regex-based alternatives), modular architecture with fine-grained control over optimizations, dual ESM/CommonJS support, built from scratch to replace the abandoned metalsmith-html-minifier with modern JavaScript practices and minimal dependencies.
npm install metalsmith-optimize-htmlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic Metalsmith setup with HTML optimization plugin, processing HTML files with comment removal and tag space stripping.
Explicitly set pattern: '**/*.{html,htm}' in options.Manually enable only the optimizations you need to avoid unintended side effects.
Place metalsmith-optimize-html after any plugins that read/transform HTML content, but before any final build steps.
Ensure HTML files are UTF-8 encoded before processing.
Use `import optimizeHTML from 'metalsmith-optimize-html'` or `const optimizeHTML = require('metalsmith-optimize-html')`.Wrap options in the plugin call: `.use(optimizeHTML({...}))`.Run `npm install metalsmith` to add it to your project.
Use `require` for CommonJS or set `"type": "module"` in package.json and use .mjs extension if needed.