8 releases

Uses new Rust 2021

new 0.1.5 Jun 23, 2022
0.1.4 Jun 22, 2022
0.0.2 Jun 18, 2022

#79 in Compression

Download history 45/week @ 2022-06-14 445/week @ 2022-06-21

490 downloads per month
Used in 2 crates


6.5K SLoC


Extremely fast JavaScript minifier, written in Rust.


  • Fully written in Rust for maximum compatibility with Rust programs and derivatives (FFI, WASM, embedded, etc.).
  • Maximises performance on a single CPU core for simple efficient scaling and easy compatible integration.
  • Minification of individual inputs/files only; no bundling or transforming.
  • Prefer minimal complexity and faster performance over maximum configurability and minimal extra compression.


Comparison with esbuild, run on common libraries.

Chart showing speed of JS minifiersChart showing compression of JS minifiers


  • Fast parsing powered by SIMD instructions and lookup tables.
  • Minification of identifiers.
  • Omits semicolons, spaces, parentheses, and braces where possible.



Precompiled binaries are available for Linux, macOS, and Windows.

Linux x64 | macOS x64 | Windows x64

Use the --help argument for more details.

minify-js --output /path/to/output.min.js /path/to/src.js


Add the dependency:

minify-js = "0.1.5"

Call the method:

use minify_js::minify;

let mut code: &[u8] = b"let x = 1;";
let mut out = Vec::new();
minify(code.to_vec(), &mut out).unwrap();
assert_eq!(out.as_slice(), b"let x=1");


Install the dependency:

npm i @minify-js/node

Call the method:

import {minify} from "@minify-js/node";

const src = Buffer.from("let x = 1;", "utf-8");
const min = minify(src);

In progress

  • Combine and reorder declarations.
  • Minify import and export syntax.
  • More extensive testing, especially over rare syntax.
  • Evaluation and folding of constant expressions.
  • Parse and erase TypeScript syntax.
  • FFI libraries for other languages.
  • Aliasing of reused well-knowns.
  • Removal of unreachable, unused, and redundant code.
  • Inlining single-use declarations.
  • Aliasing frequently accessed properties and called methods.
  • Better support for non-ASCII identifiers.
  • Replacing if statements with conditional and logical expressions.
  • Aliasing repeated identical literal values.
  • Micro-optimisations:
    • Unwrap string literal computed members, then identifier or number string members.
    • Replace x === null || x === undefined with x == null, where x is side-effect free.
    • Replace typeof x === "undefined" with x === undefined.
    • Using shorthand properties and Object.assign.
    • (Dangerous) Replace functions without use of this with arrow functions.
    • Replace void x with undefined, where x is side-effect free.
    • Replace return undefined with return.
    • Replace const with let.
    • Hoist let and const.
    • Unwrapping blocks.
    • Unwrapping paretheses, altering expressions as necessary.
    • Replace typeof and instanceof with functions.
    • if (...) return a; else if (...) return b; else return c => return (...) ? a : (...) ? b : c.


~11K SLoC