javascript-minification
它能做什么
这个技能检查发给访客的 JavaScript 是否已压缩,并去掉未使用的代码。它面向希望网站更快、更轻的开发者。
适用场景
- ✓正式环境的 JavaScript 文件比实际需要大很多的时候。
- ✓你的构建工具没有为正式环境开启压缩的时候。
- ✓你想把打包文件中未使用的代码去掉的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/javascript-minification/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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.
热度
- GitHub 星标
- 75k
- 排名
- #2902
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。