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

fetchpriority-attribute

它能做什么

这项技能检查页面如何提示其关键图片和资源的加载优先级。适用于希望页面主要内容更快出现的开发者。

适用场景

  • ✓当页面的主要首图加载很慢的时候。
  • ✓当你的页面在 Largest Contentful Paint 上得分较低的时候。
  • ✓当页面顶部有许多图片同时争夺加载资源的时候。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

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

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能