A pattern-based minifier with separate HTML, CSS, and JS modes, plus a live percentage showing how much smaller the output is. It strips comments and collapses whitespace — it does not parse, rename variables, or tree-shake. That makes it right for email templates, snippets pasted into a CMS, and inline styles, and wrong as a replacement for terser or cssnano in a build pipeline.
What each mode removes
HTML mode deletes <!-- --> comments, collapses all whitespace runs to a single space, removes whitespace between adjacent tags, and tightens spaces around = signs. CSS mode strips /* */ comments, tightens whitespace around { } : ; , > ~ +, and drops the final semicolon before each closing brace. JS mode removes // and /* */ comments using a scanner that tracks string and template-literal boundaries — so the // in a URL string like "https://example.com" survives — then tightens whitespace around operators and punctuation.
Known hazards of regex minification — check these before shipping
Because nothing here builds a syntax tree, some transformations are unsafe. In CSS, calc() expressions using + break: calc(100% + 20px) becomes calc(100%+20px), which browsers reject (subtraction happens to survive because - is not in the tightened set). In JS, a + +b becomes a++b — a different program. Whitespace inside JS strings and template literals is collapsed, so "hello world" silently becomes "hello world". In HTML, <pre> and <textarea> content is collapsed like everything else, and the = tightening applies to visible text too: <p>Price = 5</p> becomes <p>Price=5</p>.
The practical rule: minify, then eyeball the diff or run the result once. For anything with calc(), significant whitespace, or dense operator chains, use a real parser-based minifier instead.