preconnect
它能做什么
这个技能检查页面的 head 部分中的 preconnect 提示,并建议添加或移除。它面向希望字体、API 和其他第三方服务加载更快的网站构建者。
适用场景
- ✓你请智能体加快连接字体或其他外部服务速度的时候。
- ✓页面在加载早期要等待第三方域名,而你想确认提示是否有帮助的时候。
- ✓你的页面有许多 preconnect 提示,而你想移除未使用的提示的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/preconnect/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的页面在显示内容前要等待字体服务和 API。请帮我为其中重要的项目添加 preconnect 提示吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查 head 部分中已有的 preconnect 提示,并找出页面所依赖的关键外部源。它会为最重要的源添加提示,并移除未使用域名的提示。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use preconnect for critical third-party origins
Preconnecting to essential origins can shave hundreds of milliseconds off the critical path by handling connection overhead ahead of time.
Quick Reference
- Establish early connections to important third-party domains (e.g., fonts, APIs)
- Reduce latency by performing DNS lookup, TCP handshake, and TLS negotiation early
- Avoid overusing preconnect; limit to 2-4 most critical origins
Check
Review the page's head for preconnect hints and identify any missing or unnecessary connections to third-party domains.
Fix
Add <link rel="preconnect"> for critical third-party origins and remove it for non-essential or underutilized domains.
Explain
Explain how preconnect helps reduce the time spent on connection overhead for third-party resources.
Code Review
Review the routes, assets, and loading behavior that affect Use preconnect for critical third-party origins. Flag exact files, requests, or rendering steps that add unnecessary network, CPU, or layout cost, and describe the measurement method used to confirm the issue.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/performance/preconnect
常见问题
preconnect 实际做什么?
它让浏览器在请求文件之前,先解析域名、建立连接并完成安全握手。
一个页面应该有多少个 preconnect 提示?
这个技能建议限制在两到四个最关键的源。
我应该验证修改吗?
应该。这个技能建议先在 DevTools、Lighthouse 或现场数据中确认真正的瓶颈。
详情
作者的原始描述
Use when auditing slow page loads, heavy assets, or rendering delays related to Use preconnect for critical third-party origins. Verify the actual bottleneck in DevTools, Lighthouse, or field data before recommending changes.
热度
- GitHub 星标
- 75k
- 排名
- #2982
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。