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

html-resource-hints

它能做什么

这项技能检查页面中浏览器发现得太晚的重要文件。适用于希望网站首次显示更快的开发者。

适用场景

  • ✓当网络字体要等样式表被读取后才被发现的时候。
  • ✓当你的首图或关键脚本加载得比预期晚的时候。
  • ✓当你的页面使用了许多需要提前建立连接的第三方服务的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/html-resource-hints/SKILL.md

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

使用方法

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

可直接粘贴的消息

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

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

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能