<acronym title="JavaScript">JS</acronym> 压缩:

Compress JavaScript instantly. Removes whitespace, comments, and optimizes variable names. Processed 100% in your browser — your code stays private.

JavaScript Input

Minified Output

100% Private

All processing happens in your browser via Terser.js. Your code is never sent to any server.

ES2020+ Support

Terser支持现代JavaScript ,包括箭头函数、async/await、classes和模板文本。

Faster Page Load

压缩JS可将文件大小减少30–70% ,提高交互时间和核心Web Vitals分数。

What is JavaScript Minification?

JavaScript压缩是从源代码中删除所有不必要的字符而不更改其功能的过程。这包括空格、换行符、注释和长变量名称—这些名称被替换为较短的等效名称。结果是一个更小的文件,下载和解析速度更快,但功能与原始文件相同。

This tool uses Terser — the industry-standard JavaScript minifier and the engine behind Webpack, Vite, and esbuild. Terser performs both minification (removing whitespace and comments) and mangling (renaming variables to shorter names like a, b, c), achieving reductions of 30–70% depending on code style. It fully supports ES2020+ syntax including async/await, optional chaining, and nullish coalescing.

压缩JavaScript可直接改善Core Web Vitals。较小的JS捆绑包可减少交互时间(TTI)和总阻塞时间(TBT) ,这是Google在其Lighthouse审计中衡量的两个指标,并用作排名信号。Google的PageSpeed Insights会将未缩小的JavaScript标记为“消除渲染阻止资源”或“缩小JavaScript”机会。

When to Minify JavaScript

Minify JS when:

  • ✓ 部署到生产—始终提供压缩的JS
  • ✓ 您的PageSpeed Insights分数显示“压缩JavaScript”
  • ✓ 处理未预先缩小的第三方脚本
  • ✓ Reducing payload for mobile users on slow connections
  • ✓ 缩短交互时间( TTI )和总阻塞时间
  • ✓ 在部署之前组合多个小型脚本

典型的尺寸减小:

  • • Well-commented library: 50–70% reduction
  • • Typical application code: 30–50% reduction
  • • Already compressed or generated code: 10–20% reduction
  • • 顶部额外的gzip压缩:进一步60–80%

为了获得最大效果,请先压缩,然后从Web服务器使用gzip或Brotli压缩。

常见问题