legacy-js
它能做什么
这个技能检查网站是否向不需要的浏览器发送了旧版转译代码和额外的兼容性补丁(polyfill)。它面向管理构建设置的开发者。
适用场景
- ✓你的打包文件包含大量现代浏览器已支持功能的兼容性补丁的时候。
- ✓你的构建默认面向非常老的浏览器的时候。
- ✓你希望为现代浏览器提供更小、更快代码的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/legacy-js/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我设置构建,让现代浏览器获得更轻的 JavaScript 吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查构建目标和输出中的兼容性补丁。它会建议差异化分发,即使用 module 和 nomodule 脚本,以及现代的编译目标。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Avoid serving legacy JavaScript to modern browsers
Modern browsers can execute ES6+ code faster and more efficiently; serving them transpiled ES5 with polyfills adds unnecessary weight.
Quick Reference
- Use differential serving (module/nomodule) to target modern and legacy browsers
- Avoid heavy ES5 polyfills for browsers that support ES6+
- Compile code to modern targets to reduce bundle size and improve execution speed
Check
Analyze the project's JavaScript output to see if modern browsers are being served unnecessary ES5 code and polyfills.
Fix
Update the build configuration to use differential serving and set a modern target for your primary JavaScript output.
Explain
Explain how serving ES6+ code to modern browsers improves performance and why transpiling everything to ES5 is no longer recommended.
Code Review
Review the routes, assets, and loading behavior that affect Avoid serving legacy JavaScript to modern browsers. Flag exact files, requests, or rendering steps that add unnecessary network, CPU, or layout cost, and describe the measurement method used to confirm the issue.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/performance/legacy-js
常见问题
什么是差异化分发?
就是只把现代代码发给现代浏览器,只把旧代码发给需要它的浏览器。
为什么不对所有人使用 ES5?
这个技能说,现代浏览器运行 ES6 及更新的代码更快、效率更高。
目标在哪里设置?
这个技能指出,输出目标是在构建配置中选择的。
详情
作者的原始描述
Use when auditing slow page loads, heavy assets, or rendering delays related to Avoid serving legacy JavaScript to modern browsers. Verify the actual bottleneck in DevTools, Lighthouse, or field data before recommending changes.
热度
- GitHub 星标
- 75k
- 排名
- #2918
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。