GitHub - wilsonzlin/minify-js: Extremely fast JavaScript minifier, available for Rust and Node.js (original) (raw)

minify-js

Extremely fast JavaScript minifier, written in Rust.

Goals

Performance

Comparison with esbuild, run on common libraries.

Chart showing speed of JS minifiersChart showing compression of JS minifiers

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:

Call the method:

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

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

In progress