Skip to content

Count page views and project clicks with PostHog (EU servers)? It loads only if you choose Allow. Privacy

Minifier live preview
All projects

Minifier

Minify HTML, CSS, or JS without setting up a build pipeline.

Minifying a quick code snippet for embedding required build tooling just for a one-off task.

Tech Domain · Book Dev|Published|Evidence: Live|Next.js, TypeScript

A public deployment is available to try.

Case Study

Before

Quickly minifying code snippets for embedding or testing required build tooling setup. Online minifiers were slow, ad-heavy, or didn't support all web languages.

After

The page minifies a snippet in the browser and shows the source size, output size, and percentage saved.

How it's solved

Built a client-side minifier, now at /minifier in the Devtools Workbench suite, for HTML, CSS, JavaScript, and JSON. JSON is re-serialized with JSON.parse; the others use simple comment and whitespace stripping. It shows before/after size and copies the output.

Trade-offs

CSS, HTML, and JS use regex stripping, not a real parser, so unusual code (for example strings containing //) can break, and there is no renaming or dead-code removal.

Related Articles

Further reading on related topics from the blog

Related Projects

More in Tech Domain · Book Dev