Skip to content

Oxc Minifier Alpha


We are excited to announce an alpha release for oxc-minify.

While lacking some advanced minification techniques, the current version already outperforms esbuild in terms of performance and compression size, as demonstrated by minification-benchmarks.

Comparing widely-used minifiers on typescript.js:

ArtifactOriginal sizeGzip size
typescript v4.9.5 (Source)10.95 MB1.88 MB
MinifierMinified sizeMinzipped sizeTime
@swc/core🏆-70% 3.32 MB🏆-54% 858.29 kB5x2,179 ms
oxc-minify-69% 3.35 MB-54% 860.67 kB🏆 444 ms
terser (no compress)-68% 3.53 MB-53% 879.30 kB14x6,433 ms
esbuild-68% 3.49 MB-51% 915.55 kB1x492 ms
terser ❌ Timed out--⚠️ +10,000 ms

oxc-minify Usage Example

typescript
import { minify } from "oxc-minify";

const filename = "test.js";
const code = "const x = 'a' + 'b'; console.log(x);";
const options = {
  compress: {
    target: "esnext",
  },
  mangle: {
    toplevel: false,
  },
  codegen: {
    removeWhitespace: true,
  },
  sourcemap: true,
};
const result = minify(filename, code, options);

console.log(result.code);
console.log(result.map);

Next Release

oxc-minify is being integrated into Rolldown as its built-in minifier, and Rolldown is set to become the future of Vite.

So it is critical for us to:

  • Continue implementing advanced minification techniques, such as constant inlining and dead code removal.
  • Strengthen and expand our test infrastructure to ensure it is production-ready.

Acknowledgements

Thank you @sapphi-red for improving the minifier, especially the advanced symbol minification algorithm which esbuild lacks.

Released under the MIT License.