webdev_js_minifier
Minify JavaScript code by stripping comments and whitespace, mangling variable names, and optionally removing console and debugger statements to shrink file size for production.
Instructions
JavaScript Code Minifier. Minify a JavaScript snippet to shrink file size by stripping comments, collapsing whitespace, and optionally removing console/debugger statements, mangling variable names, and dropping unused code. Use this for production deployment when you only need a smaller file; use webdev_js_obfuscator instead to actively hide logic with string encoding and control-flow flattening, or webdev_javascript_beautifier to reverse compaction and re-indent. Regex-based transform, not a full parser, so output is not guaranteed runnable and is not reversible: keep the original source. Runs locally via a Node bridge: read-only, non-destructive, contacts no external service, rate-limited (60 requests per minute for anonymous callers). Returns the minified code, applied options, before/after size and line statistics, and a per-step optimization report.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript source to minify. Required and non-empty (the alias input is also accepted). | |
| level | No | Minification preset. basic does whitespace and comment stripping only; standard adds variable mangling; aggressive also removes unused code. Unknown values fall back to standard. | standard |
| removeComments | No | Strip block and line comments. | |
| removeConsole | No | Remove console log, info, warn, error, and debug calls. | |
| removeDebugger | No | Remove debugger statements. | |
| mangleVariables | No | Rename local variables to short names. Defaults to true unless level is basic. | |
| removeUnusedCode | No | Drop empty functions and dead code after return. Defaults to true only when level is aggressive. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | No | Original JavaScript source. | |
| output | No | Minified JavaScript. | |
| level | No | Effective level applied (basic, standard, or aggressive). | |
| options | No | Resolved boolean flags actually applied (removeComments, removeConsole, removeDebugger, mangleVariables, removeUnusedCode). | |
| statistics | No | Size metrics: originalSize, minifiedSize, originalLines, minifiedLines, bytesSaved, and compressionRatio percent. | |
| optimizationReport | No | Per-step entries, each with a type (success, info, or warning) and a message string. |