🗜️ JS Minifier

JS Minifier - Remove comments and extra whitespace from JavaScript for a quick size reduction, without renaming variables. Free, browser-only.

📐 工作原理与说明
依次执行:删除块注释;删除行注释;把连续空白压缩为单个空格;去掉等号、加号、减号、乘号、除号、取余、尖括号、花括号、逗号、分号、冒号、圆括号与方括号等符号两侧的空白;再次压缩空白并去掉首尾空白
压缩 JS 代码以减小体积。
  • 手段:去空白与注释、缩短标识符、删除不可达代码、合并常量。
  • 验证:压缩后必须做功能回归,确认行为未改变。
  • 叠加:与 gzip/brotli 传输压缩叠加使用,收益更明显。
  • 许可:保留 /*! … */ 形式的许可声明,满足开源协议要求。

Formula & Standard References

Item Formula / Note Source / Standard
Lexical safety removing whitespace must not change ASI outcomes ECMA-262
Name mangling local names may shorten; exports and globals may not ECMA-262
Equivalence behavior must match, especially this binding and eval ECMA-262
⚠️ 使用说明与注意事项

📋 建议

仅做快速瘦身可用本工具;CI 流水线里推荐集成 Terser 以获得更优压缩率与 tree-shaking。