EmailMinifier (v1.0.5) is a TypeScript-based email minifier for browser and Node.js that specializes in reducing email HTML size, unlike generic HTML minifiers. It minifies IDs, classes, data-* attributes, and CSS within style tags, and can remove unused custom attributes. Version 1.0.5 is the latest stable release; maintainers commit irregularly. Key differentiators include handling email-specific constraints (no JS, limited interactivity, Gmail cropping) and providing a simple async API.
npm install email-minifierNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import EmailMinifier, create an instance with an email HTML string, call minify() with options, and access the minified result, original size, and tasks.
Always await or use .then() when calling minify().
Check for null before using result.minified, or fallback to result.original.
Ensure array elements are RegExp instances, e.g., [new RegExp('custom-test-id')].Use named import: import { EmailMinifier } from 'email-minifier'Run npm install email-minifier and ensure the import is exactly 'email-minifier'.
For CommonJS, use const { EmailMinifier } = require('email-minifier'). For ESM, use import.No dependency data recorded yet.