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

legacy-js

它能做什么

这个技能检查网站是否向不需要的浏览器发送了旧版转译代码和额外的兼容性补丁(polyfill)。它面向管理构建设置的开发者。

适用场景

  • ✓你的打包文件包含大量现代浏览器已支持功能的兼容性补丁的时候。
  • ✓你的构建默认面向非常老的浏览器的时候。
  • ✓你希望为现代浏览器提供更小、更快代码的时候。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能