assetopt

Guide

Minify CSS & JS from the command line

Minify CSS and JavaScript files in bulk from the command line — one tool that also handles images and SVG. Runs locally, no bundler config, MIT.

Most projects minify CSS and JS through a bundler. But sometimes you just have a folder of .css and .js files — a static site, a shared component library, a WordPress theme, a handful of vendored scripts — and wiring up a full build for it is overkill. This guide minifies those files in bulk from the command line, with the same tool that also handles your images and SVG.

Everything runs against @assetopt/cli (open source, MIT).

Install

npm install -g @assetopt/cli

Minify a folder

CSS and JS minification are on by default, so the minimum config is nothing at all. Point assetopt at the folder:

assetopt optimize ./assets

Every .css and .js under ./assets is minified into ./optimized, keeping the same names and extensions. Under the hood, CSS goes through lightningcss and JS through esbuild — whitespace, identifiers, and syntax.

To be explicit (or to toggle either off), spell it out in .assetoptrc:

{
  "css": { "minify": true },
  "js": { "minify": true },
  "output": { "dir": "./optimized" }
}

Preview first

assetopt analyze ./assets

analyze is a dry run — it prints the per-file before/after without writing anything.

Real numbers

From the downloadable sample pack:

File Type Before After Saved
main.css CSS 2,196 B 1,506 B −31.4%
app.js JS 2,441 B 984 B −59.7%

These are real outputs, minification only — no format change, no renaming. JS compresses harder because identifier renaming and dead-code removal have more to work with; CSS is mostly whitespace and shorthand collapsing.

Only touch the code, not the images

If a folder mixes assets and you want to skip images entirely for this run, use images.skip to drop each source format from the pipeline:

{
  "images": { "skip": ["jpeg", "png", "webp", "avif"] },
  "css": { "minify": true },
  "js": { "minify": true }
}

Skipped files are not read, not written, and absent from the report. See the config reference.

SVG too

assetopt also optimizes SVG (via svgo, multipass by default). It’s part of the same run — anything under the target folder gets handled by type. See the feature catalog for the SVG options.

Next steps

Get the CLI

$ npm install -g @assetopt/cli

Open source, MIT. See the docs orstar it on GitHub.