x ai deno minify js
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:
-
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
-
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
--minify— Enables whitespace removal, comment stripping, and basic optimizations.--platform browser(ordeno) — Useful when targeting the browser.--sourcemap— Generate source maps alongside the minified output.
Example from official docs:
# Bundle with minification deno bundle --minify main.ts # For executables deno compile --bundle --minify main.ts
Additional Notes
- Deno’s minifier is fast and handles TypeScript, JSX/TSX, and dependencies (including npm/JSR) out of the box.
- For more advanced needs (e.g., heavy mangling or custom config), you can still pipe the output through tools like Terser.
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!