esbuild – An extremely fast JavaScript bundler and minifier

Interesting work by Evan Wallace, a JS bundler/minifier written in Go. Since it compiles down to native code, it’s fast:

My main benchmark approximates a large codebase by duplicating the three.js library 10 times and building a single bundle from scratch, without any caches. For this benchmark, esbuild is 10-100x faster than the other JavaScript bundlers I tested (Webpack, Rollup, Parcel, and FuseBox).

It supports quite a lot of stuff, but is not considered to cover it all:

This is a hobby project that I wrote over the 2019-2020 winter break. I believe that it’s relatively complete and functional. However, it’s brand new code and probably has a lot of bugs. It also hasn’t yet been used in production by anyone. Use at your own risk.

Example usage:

# Produces dist/entry_point.js and dist/entry_point.js.map
esbuild --bundle entry_point.js --outdir=dist --minify --sourcemap

Also works with React, with some extra CLI arguments:

esbuild example.jsx --bundle '--define:process.env.NODE_ENV="production"' --minify --outfile=out.js

esbuild

Minify: A JavaScript and CSS Minifier Written in PHP

php-logo

MatthiasMullie\Minify is a JavaScript and CSS Minifier written in PHP. Usage is straightforward:

use MatthiasMullie\Minify;

$sourcePath = '/path/to/source/css/file.css';
$minifier = new Minify\CSS($sourcePath);

// we can even add another file, they'll then be
// joined in 1 output file
$sourcePath2 = '/path/to/second/source/css/file.css';
$minifier->add($sourcePath2);

// or we can just add plain CSS
$css = 'body { color: #000000; }';
$minifier->add($css);

// save minified file to disk
$minifiedPath = '/path/to/minified/css/file.css';
$minifier->minify($minifiedPath);

// or just output the content
echo $minifier->minify();

The JavaScript version syntax is the same, just swap out the CSS classes with JS classes.

Install MatthiasMullie\Minify using composer:

composer require matthiasmullie/minify

MatthiasMullie\Minify Source (GitHub) →
Minifier (Demo/Hosted Minify Implementation) →