fetchpriority-attribute
它能做什么
这项技能检查页面如何提示其关键图片和资源的加载优先级。适用于希望页面主要内容更快出现的开发者。
适用场景
- ✓当页面的主要首图加载很慢的时候。
- ✓当你的页面在 Largest Contentful Paint 上得分较低的时候。
- ✓当页面顶部有许多图片同时争夺加载资源的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/fetchpriority-attribute/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请告诉浏览器优先加载我的首图。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找到首屏中最大的图片,并建议为其添加高优先级提示。它也可以建议降低页面下方图片的优先级。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use fetchpriority to hint resource loading priority
Browsers use internal heuristics to guess resource priority, but they cannot know which image is your LCP candidate. Adding fetchpriority="high" to the LCP image has been shown to reduce LCP by 5–30 % in real-world tests, directly improving Core Web Vitals scores and user-perceived load speed. The attribute costs nothing to add and is the lowest-effort high-impact performance optimisation available today.
Quick Reference
- Add fetchpriority="high" to the LCP image to accelerate Largest Contentful Paint
- Add fetchpriority="low" to below-the-fold images that would otherwise compete with critical resources
- Use fetchpriority="high" on <link rel="preload"> for critical fonts and CSS
- Avoid marking more than one or two resources as high priority — it defeats the purpose
Check
Check whether the LCP image or hero element has fetchpriority="high" and whether any high-priority preload links are missing the attribute.
Fix
Add fetchpriority="high" to the LCP image element and any preloaded critical resources, and fetchpriority="low" to non-critical below-the-fold images.
Explain
Explain how the browser's resource priority queue works and how fetchpriority hints change loading order to improve LCP.
Code Review
Review the HTML for images above the fold. Flag the LCP candidate if it lacks fetchpriority="high", and flag any carousel or below-fold images that lack fetchpriority="low" (they compete with critical resources).
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/performance/fetchpriority-attribute
常见问题
fetchpriority 有什么作用?
它是一个 HTML 属性,提示资源的重要程度,使浏览器能以更好的顺序加载它。
它能有多大帮助?
这项技能引用了实际测试,在 Largest Contentful Paint 上有约 5% 到 30% 的提升。
每张图片都应设为高优先级吗?
不应。这项技能提醒说,将超过一两个资源标记为高优先级,就失去了这一设置的意义。
详情
作者的原始描述
Use when optimising Largest Contentful Paint (LCP), reducing render-blocking resource contention, or fine-tuning resource loading order in the critical rendering path.
热度
- GitHub 星标
- 75k
- 排名
- #2842
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。