Irreva logo
Explore Irreva
DeveloperFebruary 3, 2026· 6 min read· Updated June 10, 2026

How to Minify JavaScript Online Free

Hasanur Rahman

Written by Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

JavaScript minification is a standard step in every web production build. A single JS bundle for a modern web app can easily be hundreds of kilobytes. Minification strips comments, removes whitespace, and shortens variable names to produce a functionally identical but significantly smaller file. Less bytes to download means faster page loads — and faster pages rank better and convert better.

What JavaScript minification does to your code

Basic minification removes comments and whitespace — the same operations as CSS minification. But JS minifiers can go further because they understand code structure, not just text.

Variable renaming is the most impactful transformation. Long, descriptive names like calculateShippingCost become single-letter names like a. This doesn't change what the code does but can reduce file size substantially in a function-heavy codebase.

Dead code elimination removes code that is never executed — unreachable branches, unused functions, and console.log statements flagged for removal. This requires the minifier to understand the code's control flow.

  • Removes comments and whitespace
  • Shortens variable and function names
  • Removes dead code and unreachable branches
  • Replaces string literals with shorter equivalents where safe
  • Inlines small functions
  • Simplifies constant expressions (1 + 2 → 3)

Minification vs bundling vs tree-shaking

These are three different optimizations that often happen together in a build pipeline. Bundling combines multiple JS files into one to reduce HTTP requests. Tree-shaking removes exported code that is never imported or used anywhere in the project. Minification compresses the resulting bundle.

All three together produce the smallest possible output. Modern bundlers like Vite, webpack, and Rollup apply all three automatically in production mode. Esbuild and SWC are newer, significantly faster minifiers that are becoming standard in build tools.

For a quick one-off minification task — a standalone script, a bookmarklet, a widget you're copying into a CMS — an online minifier is faster than setting up a build pipeline.

How to minify JavaScript with the online tool

The Irreva JS Minifier accepts JavaScript code, minifies it in the browser, and gives you the output to copy. It handles modern JavaScript including ES6+ features: arrow functions, template literals, destructuring, spread operators, and async/await.

Paste your code, copy the minified output, and use it in your project. No server required, no account, no rate limits. The tool runs entirely in your browser using a JavaScript parsing library.

For source maps — which allow browser devtools to show you the original unminified code for debugging — you'll need a proper build tool like esbuild or webpack. Source map generation isn't available in the online minifier.

When to minify and when not to

Always minify code that goes to production. Don't minify code you're actively developing, debugging, or that other developers need to read. The minified version is for browsers; the readable version is for humans.

If you're publishing an open-source library, publish both the minified and the unminified version. Many package managers and CDNs expect a .min.js convention for the minified build.

Some developers also add a copy of the source to the production site via source maps, so that error monitoring tools like Sentry can map minified stack traces back to the original code.

Frequently Asked Questions

Will minified JavaScript run differently than the original?

It should be functionally identical. A correctly written minifier only removes redundant characters and renames local variables in ways that don't change behavior. If you encounter a bug that only appears in minified code, it's usually caused by an overly aggressive optimization or code that relies on function.name or variable naming at runtime.

Can I minify TypeScript directly?

TypeScript must be compiled to JavaScript before minification. The TypeScript compiler (tsc) can output minified JS with the right options, or you can use esbuild or SWC which handle both transpilation and minification in one fast step.

What is Terser and should I use it?

Terser is currently the most widely used JavaScript minifier, used by webpack, Vite, and others under the hood. It produces excellent minification with configurable options. For most projects, you're already using Terser without knowing it through your build tool.

How much size reduction can I expect?

Typically 30–60% reduction in raw file size before gzip. After gzip or Brotli, both minified and unminified code compress significantly, but minified code is still smaller in the end. A 100KB bundle commonly becomes 40–70KB after minification.

Does minification break eval() or Function()?

It can, if you use eval() or new Function() with code that references variable names — since those names get renamed during minification. Using eval is generally bad practice for multiple reasons; this is one more. Avoid eval in modern code.

Hasanur Rahman

About the author

Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

Hasanur Rahman is the founder of Irreva and a full-stack developer based in Rangpur, Bangladesh. He builds all of Irreva's tools with a focus on privacy-first, browser-based processing.