Batch JavaScript Minifier

All processing happens locally in your browser. No uploads. No tracking. Full privacy.

Select JavaScript Files

Terser Options






⚙️ Browser-Based JavaScript Minification Pipeline

A practical, privacy-first build system running entirely in the browser

1. What this thing actually is

This system is basically a mini build tool that runs fully inside your browser. You pick JavaScript files, it minifies them, and you download the optimized versions.

No servers. No uploads. No waiting on external APIs. Everything happens locally. Think of it like a lightweight version of Webpack or Vite—but stripped down and focused only on minification.

The whole idea: your code never leaves your machine.

2. The main pieces

UI Layer (index.html)

This is where you interact with the tool:

  • Select JS files
  • See progress
  • Start the minification process
  • Download results

Orchestration Layer (app.js)

This is the “brain” of the system. It:

  • Manages Web Workers
  • Keeps track of progress
  • Queues files
  • Builds the final ZIP

Execution Layer (worker.js)

This is where the actual minification happens using Terser. Each worker processes a file independently.

3. Why this architecture is interesting

Instead of doing everything on the main thread (which would freeze the UI), the system spreads work across multiple Web Workers.

So while one file is being compressed, others are processed in parallel. The UI stays smooth the whole time.

Browsers are single-threaded for UI—but Web Workers let you cheat that limitation.

4. Terser: the minification engine

At the core of everything is Terser, a powerful JavaScript minifier. It takes your code and performs a bunch of transformations:

  • Removes dead code
  • Renames variables (mangling)
  • Simplifies expressions
  • Removes console logs (if enabled)
const result = await Terser.minify(code, {
    compress: {
        passes: 2
    },
    mangle: true,
    format: {
        comments: false
    }
});

Basically: same logic, smaller file, faster load time.

5. Web Workers: the secret sauce

JavaScript normally runs on a single thread. That means heavy tasks can freeze the page.

Web Workers fix that by spawning isolated threads. Each file gets its own worker (or shared pool of workers).

const MAX_WORKERS = Math.min(3, navigator.hardwareConcurrency || 4);

This ensures:

  • We don’t overload the CPU
  • We use multiple cores efficiently
  • The browser stays responsive

6. JSZip: packaging everything

Once all files are minified, they need to be downloaded. Instead of giving you 20 separate downloads, we bundle everything into a ZIP file.

const zip = new JSZip();

files.forEach(file => {
    zip.file(file.name, file.blob);
});

const blob = await zip.generateAsync({ type: "blob" });

Then we generate a temporary download link using URL.createObjectURL.

7. Performance considerations

This system is fast, but it still has limits.

Good parts

  • Parallel processing with workers
  • No network latency
  • Lightweight runtime

Constraints

  • Browser memory limits
  • Large files can slow things down
  • Too many workers = diminishing returns
Sweet spot: small to medium JS projects, not giant production bundles.

8. UX decisions

A big focus of this system is making it feel instant and transparent.

  • Live progress bar
  • Per-file logs
  • Size reduction feedback (e.g. 10KB → 3KB)

This helps users actually understand what’s happening instead of waiting blindly.

9. Security model

One of the strongest points: nothing leaves the browser.

  • No uploads
  • No backend
  • No external processing

This removes a lot of risk:

  • No data leaks
  • No server vulnerabilities
  • No dependency on APIs

10. How it compares to traditional build tools

Feature Browser Tool Node.js Build Tools
Privacy ✔ Fully local ❌ Often server-based pipelines
Setup ✔ Zero config ❌ Requires tooling
Automation ❌ Limited ✔ Strong CI/CD support
Performance âš– Medium scale âś” Highly scalable

11. Where it shines (and where it doesn’t)

Best use cases

  • Quick JS optimization
  • Small projects
  • Offline environments
  • Privacy-sensitive workflows

Not ideal for

  • Huge production builds
  • CI/CD pipelines
  • Enterprise-scale bundling

12. Possible improvements

  • Streaming minification (don’t load full files at once)
  • WASM-based minifiers (even faster parsing)
  • Incremental builds (only process changed files)
  • Better drag-and-drop UX

13. Final thoughts

This system is more than just a utility—it’s a demonstration of what modern browsers can do. It turns the browser into a lightweight build environment.

By combining:

  • Terser for optimization
  • Web Workers for parallelism
  • JSZip for packaging

you get a surprisingly powerful, fully local development tool.

The real takeaway: browsers aren’t just for viewing apps anymore—they can *build* them too.