跳到正文
Skillpedia
网站与界面(前端)75k · #2902

javascript-minification

它能做什么

这个技能检查发给访客的 JavaScript 是否已压缩,并去掉未使用的代码。它面向希望网站更快、更轻的开发者。

适用场景

  • ✓正式环境的 JavaScript 文件比实际需要大很多的时候。
  • ✓你的构建工具没有为正式环境开启压缩的时候。
  • ✓你想把打包文件中未使用的代码去掉的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/javascript-minification/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/javascript-minification/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我确认正式环境中的 JavaScript 已经压缩了吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查正式构建的设置,并建议使用 Terser 等压缩工具,以及用于去除未使用代码的 tree-shaking。它会确认输出文件确实变小了。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Minify all JavaScript files

Unminified JavaScript adds hundreds of KB to page weight, slowing down load times especially on mobile networks where every byte counts.

Quick Reference

  • Enable minification in your build tool (Vite, webpack, etc.)
  • Use Terser for modern JavaScript minification
  • Enable tree-shaking to remove unused code
  • Typical reduction: 50-70% file size savings

Check

Verify that all JavaScript files are minified in production to reduce file size, remove comments, and optimize code for faster loading and execution.

Fix

Configure your build system to minify JavaScript files using tools like Terser, UglifyJS, or built-in framework minification for production deployment.

Explain

Explain how JavaScript minification improves website performance by reducing bundle sizes, eliminating dead code, and optimizing parsing speed.

Code Review

Review scripts, client components, and browser execution paths related to Minify all JavaScript files. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/javascript-minification

常见问题

文件能小多少?

这个技能说,压缩通常能把文件大小减少 50% 到 70%。

什么是 tree-shaking?

它会从最终的打包文件中去掉未使用的代码,让访客下载的内容更少。

文中提到了哪些工具?

这个技能提到了 Terser、UglifyJS 以及框架内置的压缩功能。

详情

作者的原始描述

Use when reviewing scripts, client components, bundles, or runtime behavior related to Minify all JavaScript files. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2902
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能