x ai deno minify js

By Xah Lee. Date: .
xtodo

Yes, Deno can minify your TypeScript/JavaScript code.

How to Minify with Deno

Deno provides built-in minification (powered by esbuild) through its bundling commands:

  1. deno bundle --minify

    • Creates a single-file bundle and minifies it.
    • Great for browser or library bundles.
    deno bundle --minify main.ts output.bundle.js
    
  2. deno compile --bundle --minify

    • Compiles your code into a standalone executable and minifies the embedded bundle.
    • Reduces both file size and runtime memory usage (useful for CLIs and deployed apps).
    deno compile --bundle --minify --allow-net main.ts
    

Key Options

Example from official docs:

# Bundle with minification
deno bundle --minify main.ts

# For executables
deno compile --bundle --minify main.ts

Additional Notes

This is a nice advantage over plain tsc — Deno gives you minification without extra dependencies for many common use cases. Let me know what you're building (web app, CLI, etc.) if you want a more specific command!