Skip to content

Syntax Normalization

Oxc minifier supports transforming syntaxes to make the output shorter and repetitive.

This feature is enabled by default and can be disabled by setting the compress option to false.

Target

Oxc minifier uses some syntaxes that are only supported in newer environments. You can specify the target environment by setting the target option. The default value is esnext, which allows the use of any syntaxes that are supported by the latest ECMAScript standard. The supported value is same as the target option in the transformer.

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

const result = await minify("lib.js", code, {
  compress: {
    target: "chrome87",
  },
});
``````js
// input
var foo = 1;
var bar = 2;

// output
var foo = 1,
  bar = 2;
``````js
// Example
import { minify } from "oxc-minify";

const result = await minify("lib.js", code, {
  compress: {
    joinVars: false,
  },
});
``````js
// input
foo();
bar();

// output
(foo(), bar());
``````js
// Example
import { minify } from "oxc-minify";

const result = await minify("lib.js", code, {
  compress: {
    sequences: false,
  },
});