js-redirects
它能做什么
这个技能找出用 JavaScript 进行跳转的页面,并建议改用服务器端跳转。它面向希望导航更快、对搜索引擎更友好的开发者。
适用场景
- ✓页面加载后,用脚本把访客转到别处的时候。
- ✓你调整了页面,跳转感觉很慢的时候。
- ✓搜索引擎似乎难以处理你的跳转的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/js-redirects/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我把网站上的 JavaScript 跳转换成正确的服务器跳转吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会在代码中搜索 window.location 跳转,并建议把它们改为 Web 服务器或边缘配置中的 301 或 302 规则。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Avoid JavaScript-based redirects
JavaScript redirects force an additional round-trip after the initial page load, significantly increasing the time users spend waiting for content.
Quick Reference
- Use 301 or 302 server-side redirects instead of
window.location - JS redirects delay page load as the browser must first download and execute the script
- Client-side redirects can negatively impact SEO and indexability
Check
Check the project for instances where JavaScript is being used for page-level redirects (e.g., window.location).
Fix
Replace JavaScript-based redirects with server-side 301 or 302 redirects in your web server or edge configuration.
Explain
Explain why server-side redirects are faster and more SEO-friendly than client-side JavaScript redirects.
Code Review
Review the routes, assets, and loading behavior that affect Avoid JavaScript-based redirects. 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/js-redirects
常见问题
服务器跳转为什么更快?
这个技能说,JavaScript 跳转需要先加载页面和脚本,这会多出一次往返。
服务器跳转对搜索引擎优化更好吗?
这个技能说,客户端跳转可能损害搜索引擎优化,而服务器端跳转对搜索引擎更友好。
跳转应该设置在哪里?
这个技能建议设置在 Web 服务器或边缘配置中。
详情
作者的原始描述
Use when auditing slow page loads, heavy assets, or rendering delays related to Avoid JavaScript-based redirects. Verify the actual bottleneck in DevTools, Lighthouse, or field data before recommending changes.
热度
- GitHub 星标
- 75k
- 排名
- #2905
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。