# Minify JavaScript source code

> Remove comments and unnecessary whitespace from JavaScript using a conservative server-side minifier.

Canonical: https://staticx.site/js-minifier

## Compact small scripts

Remove comments and extra whitespace from small JavaScript files used by static pages.

## Conservative output

This utility is for simple scripts, not a replacement for a full bundler or tree shaker.

## Keep source readable

Store readable JavaScript somewhere before replacing public assets with minified code.

## How to use JS Minifier

Compact small JavaScript snippets after behavior has already been tested in the page.

1. **Paste JavaScript** — Use a small script or snippet that has already been tested.
2. **Minify JS** — StaticX returns compact JavaScript suitable for review and preview.
3. **Test behavior** — Preview the page and confirm forms, buttons, and analytics still behave correctly.

## JavaScript minification is safest after behavior is already correct.

Whitespace is rarely the reason a script fails, but minifying an untested script can hide problems and make debugging harder.

Use project build tools for application bundles. Use this utility for smaller static-site scripts that need a quick cleanup.

## JavaScript minification notes

- **Not a bundler** — It does not resolve imports, transpile TypeScript, or remove unused packages.
- **Avoid secrets** — Public JavaScript is visible to visitors. Never include private tokens or keys.
- **Preview interactions** — Always test the page after replacing JavaScript.

## FAQ

### Can I minify a full React bundle?

Use the React or Vite build process instead. This tool is intended for small scripts and snippets.

### Does minification hide source code?

No. Public JavaScript remains downloadable by visitors even when minified.

### Can this fix JavaScript errors?

No. Fix errors before minifying.

[View on staticx.site](https://staticx.site/js-minifier)
