third-party-scripts
它能做什么
这项技能检查网页上的外部脚本,例如分析、广告和聊天小组件。适用于发现页面加载缓慢的开发者和网站所有者。
适用场景
- ✓当页面因分析、广告或聊天脚本而感觉很慢的时候。
- ✓当页面上的 script 标签缺少 async 或 defer 属性的时候。
- ✓当性能审计指出第三方代码是瓶颈的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/third-party-scripts/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的网站加载很慢,我怀疑是聊天小组件和分析工具造成的。请帮我检查它们的加载方式。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查每个外部脚本的加载方式,以及它是否阻塞页面。它会建议使用 async、defer 或懒加载,并先用测量数据确认真正的瓶颈。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Optimize third-party script loading
Third-party scripts are the #1 cause of slow websites—unoptimized loading can add 2-5 seconds to your page load time.
Quick Reference
- Use async for independent scripts (analytics, ads)
- Use defer for DOM-dependent scripts (chat widgets, social)
- Lazy-load non-critical scripts after page load
- Consider self-hosting critical third-party scripts
Check
Analyze third-party scripts on this page to ensure they use async/defer and don't block rendering.
Fix
Add async or defer attributes to third-party scripts and consider lazy loading non-critical scripts.
Explain
Explain the performance impact of third-party scripts and strategies to minimize their blocking effect.
Code Review
Review the routes, assets, and loading behavior that affect Optimize third-party script loading. 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/third-party-scripts
常见问题
脚本应该何时使用 async 或 defer?
这项技能建议对分析等独立脚本使用 async,对依赖页面的脚本(例如聊天小组件)使用 defer。
我应该自己托管这些脚本吗?
这项技能指出,对于关键的第三方脚本,自托管可能是合理的。
这项技能如何确认某个脚本确实拖慢了页面?
在建议修改之前,它会查看浏览器开发者工具、Lighthouse 或真实用户数据中的证据。
详情
作者的原始描述
Use when auditing slow page loads, heavy assets, or rendering delays related to Optimize third-party script loading. Verify the actual bottleneck in DevTools, Lighthouse, or field data before recommending changes.
热度
- GitHub 星标
- 75k
- 排名
- #3057
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。