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

js-redirects

它能做什么

这个技能找出用 JavaScript 进行跳转的页面,并建议改用服务器端跳转。它面向希望导航更快、对搜索引擎更友好的开发者。

适用场景

  • ✓页面加载后,用脚本把访客转到别处的时候。
  • ✓你调整了页面,跳转感觉很慢的时候。
  • ✓搜索引擎似乎难以处理你的跳转的时候。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

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

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能