speculation-rules
它能做什么
这个技能为可能的下一页设置浏览器的推测规则(Speculation Rules)功能,并检查规则是否过于宽泛。它面向希望多页网站页面切换更快的网站构建者。
适用场景
- ✓你请智能体让网站页面之间的导航感觉更快的时候。
- ✓页面切换感觉很慢,而访客经常前往相同的几个下一页的时候。
- ✓你希望检查推测规则,确保它们不会加载无关或个人页面的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/speculation-rules/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我网站的页面之间切换感觉很慢。请帮我添加推测规则,让下一页提前加载吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会添加一个推测规则代码块,针对最可能的下一页链接。它先使用预取(prefetch)提前加载 HTML,并建议对很可能被打开的页面使用预渲染(prerender)。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use the Speculation Rules API to prefetch and prerender navigations
Navigation latency is one of the biggest contributors to poor Interaction to Next Paint (INP) and overall perceived performance. Prerendering the most likely next page eliminates all network and rendering latency — the user sees the new page in under 100 ms regardless of server response time. Google Search has used this API to deliver its "instant" results page experience.
Quick Reference
- Use prefetch rules to load the next page's HTML ahead of time
- Use prerender rules to fully render the next page in the background (instant navigation)
- Scope rules with href-matches or CSS selector patterns to avoid wasting bandwidth
- Prefer document rules (CSS selectors) over URL list rules for dynamic sites
Check
Check whether the site uses the Speculation Rules API or equivalent prefetch/prerender techniques for likely navigation targets.
Fix
Add a Speculation Rules JSON block targeting the most likely next-page links, starting with prefetch and graduating to prerender.
Explain
Explain how the Speculation Rules API differs from rel=prefetch and rel=prerender, and how prerendering achieves near-zero navigation latency.
Code Review
Review speculation rule selectors for over-eagerness — flag patterns that would prerender unrelated pages, third-party URLs, or pages with personalised/authenticated content that should not be pre-fetched.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/performance/speculation-rules
常见问题
预取和预渲染有什么区别?
这个技能说,预取会提前加载页面的 HTML,而预渲染会在后台完整渲染页面。
这会浪费流量吗?
如果规则过于宽泛,可能会。因此这个技能建议将其范围严格限定。
个人页面应该包括在内吗?
不应该。这个技能说,应避免预渲染个性化或需要登录的页面。
详情
作者的原始描述
Use when optimising multi-page navigation performance, reducing INP on page transitions, or implementing progressive enhancement for fast page loads.
热度
- GitHub 星标
- 75k
- 排名
- #3032
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。