html-resource-hints
它能做什么
这项技能检查页面中浏览器发现得太晚的重要文件。适用于希望网站首次显示更快的开发者。
适用场景
- ✓当网络字体要等样式表被读取后才被发现的时候。
- ✓当你的首图或关键脚本加载得比预期晚的时候。
- ✓当你的页面使用了许多需要提前建立连接的第三方服务的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/html-resource-hints/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请添加 preload 提示,使我的主要字体和首图加载得更早。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会查找加载较晚的关键资源,并为它们建议 preload 提示。对于页面早期使用的第三方域名,它还会建议 preconnect。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Add resource hints (preload, prefetch, dns-prefetch)
The browser's HTML parser discovers resources sequentially — a font referenced in a CSS file won't be fetched until the CSS is parsed. Resource hints break this dependency chain, allowing the browser to start fetching critical resources in parallel with parsing. A single preload directive for a critical font can eliminate a 100–300ms Flash of Invisible Text.
Quick Reference
- preload forces immediate download of resources needed by the current page
- prefetch fetches resources likely needed for the next navigation (low priority)
- dns-prefetch resolves DNS for third-party origins in advance
- preconnect does DNS + TCP + TLS for origins you'll connect to soon
Check
Look at this HTML file for late-discovered critical resources — fonts referenced in CSS, hero images, and key scripts. Identify where preload or preconnect hints would help.
Fix
Add appropriate preload hints for critical fonts, images, and scripts. Add preconnect for third-party domains used early in the page.
Explain
Explain each resource hint type (preload, prefetch, preconnect, dns-prefetch), when to use each, and the consequences of misusing them.
Code Review
Review templates, server-rendered HTML, and shared components that output markup related to Add resource hints (preload, prefetch, dns-prefetch). Flag exact elements, attributes, and routes where the rendered HTML violates the rule.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/en/rules/html/html-resource-hints
常见问题
preload 和 prefetch 有什么区别?
preload 获取当前页面现在需要的内容;prefetch 则以低优先级获取下一个页面可能需要的内容。
preconnect 有什么作用?
它提前与网站建立连接,包括 DNS、TCP 和 TLS,使之后的请求开始得更快。
什么是 dns-prefetch?
它提前解析第三方域名。它是比 preconnect 更轻量的选择。
详情
作者的原始描述
Use when reviewing templates, rendered HTML, or shared components related to Add resource hints (preload, prefetch, dns-prefetch). Validate the final browser-facing markup, not just the source framework abstraction.
热度
- GitHub 星标
- 75k
- 排名
- #2871
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。