Crates.io | oxc_minifier |
lib.rs | oxc_minifier |
version | 0.83.0 |
created_at | 2023-07-06 07:37:53.943925+00 |
updated_at | 2025-08-29 06:54:57.218177+00 |
description | A collection of JavaScript tools written in Rust. |
homepage | https://oxc.rs |
repository | https://github.com/oxc-project/oxc |
max_upload_size | |
id | 909652 |
size | 655,869 |
A JavaScript minifier has three components:
The compressor is responsible for rewriting statements and expressions for minimal text output. Terser is a good place to start for learning the fundamentals.
The mangler implementation is part of the SymbolTable
residing in oxc_semantic
.
It is responsible for shortening variables. Its algorithm should be gzip friendly.
The printer is also responsible for printing out the shortened variable names.
The printer is responsible for removing whitespace from the source text.
Infinity
, parseInt
, Object
, Promise.resolve
globalThis.Object = class MyObject {}
name
property of Function
or Class
function fn() {}; console.log(f.name === 'fn')
document.all
is not used or behaves as a normal object
console.log(typeof document.all === 'undefined')
(() => { console.log(v); let v; })()
with
statement is not used
with (Math) { console.log(PI); }
.toString()
, .valueOf()
, [Symbol.toPrimitive]()
are side-effect free
{ toString() { console.log('sideeffect') } }
try { new Array(Number(2n**53n)) } catch { console.log('log') }
const v = []; class A extends v {}
The fixtures are copied from https://github.com/terser/terser/tree/v5.9.0/test/compress