Home

Awesome

minify-js

Extremely fast JavaScript minifier, written in Rust.

Goals

Performance

Comparison with esbuild, run on common libraries.

<img width="400" alt="Chart showing speed of JS minifiers" src="https://static.wilsonl.in/minify-js/bench/0.6.0/total-times.svg"><img width="400" alt="Chart showing compression of JS minifiers" src="https://static.wilsonl.in/minify-js/bench/0.6.0/average-sizes.svg">

Features

Usage

CLI

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

Rust

Add the dependency:

[dependencies]
minify-js = "0.6.0"

Call the method:

use minify_js::{Session, TopLevelMode, minify};

let mut code: &[u8] = b"const main = () => { let my_first_variable = 1; };";
let session = Session::new();
let mut out = Vec::new();
minify(&session, TopLevelMode::Global, code, &mut out).unwrap();
assert_eq!(out.as_slice(), b"const main=()=>{let a=1}");

Node.js

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