重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
perf-web-optimization by tech-leads-club/agent-skills
npx skills add https://github.com/tech-leads-club/agent-skills --skill perf-web-optimization系统性方法:测量 → 识别 → 优先级排序 → 实施 → 验证。
| 指标 | 良好 | 需要改进 | 较差 |
|---|---|---|---|
| LCP | < 2.5s | 2.5-4s | > 4s |
| INP | < 200ms | 200-500ms | > 500ms |
| CLS | < 0.1 | 0.1-0.25 | > 0.25 |
| TTFB | < 800ms | 800ms-1.8s | > 1.8s |
<!-- 首屏/LCP 图片:eager + 高优先级 -->
<img src="/hero.webp" alt="Hero" width="1200" height="600" loading="eager" fetchpriority="high" decoding="async" />
<!-- 首屏下方:懒加载 -->
<img src="/product.webp" alt="Product" width="400" height="300" loading="lazy" decoding="async" />
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
始终设置 width 和 height 以防止 CLS。
<!-- 预连接到字体源 -->
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<!-- 非阻塞字体加载 -->
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter&display=swap"
media="print"
onload="this.media='all'"
/>
<!-- 延迟到用户交互时加载 -->
<script>
function loadThirdParty() {
// 加载分析工具、聊天插件等
}
;['scroll', 'click', 'touchstart'].forEach((e) => addEventListener(e, loadThirdParty, { once: true, passive: true }))
setTimeout(loadThirdParty, 5000)
</script>
将关键 CSS 内联在 <head> 中,其余部分延迟加载:
<style>
/* 关键样式 */
</style>
<link rel="preload" href="/styles.css" as="style" onload="this.rel='stylesheet'" />
# Webpack
npx webpack-bundle-analyzer dist/stats.json
# Vite
npx vite-bundle-visualizer
# 安装前检查包大小
npx bundlephobia <package-name>
常见需要替换的臃肿包:
moment (67KB) → date-fns (12KB) 或 dayjs (2KB)lodash (72KB) → 按需导入或使用原生方法// React lazy
const Chart = lazy(() => import('./Chart'))
// Next.js dynamic
const Admin = dynamic(() => import('./Admin'), { ssr: false })
// Vite/Rollup 手动分块
build: {
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom']
}
}
}
}
# 静态资源(文件名中包含不可变哈希)
Cache-Control: public, max-age=31536000, immutable
# HTML(重新验证)
Cache-Control: no-cache
# API 响应
Cache-Control: private, max-age=0, must-revalidate
要进行审计、阅读报告和设置预算,请使用 perf-lighthouse 技能。
srcsetwidth/height 属性loading="lazy"fetchpriority="high"font-display: swap有关深入的优化模式,请参阅:
每周安装量
67
代码仓库
GitHub 星标数
1.9K
首次出现
2026年2月5日
安全审计
安装于
opencode66
gemini-cli64
codex64
github-copilot64
amp62
kimi-cli62
Systematic approach: Measure → Identify → Prioritize → Implement → Verify.
| Metric | Good | Needs Work | Poor |
|---|---|---|---|
| LCP | < 2.5s | 2.5-4s | > 4s |
| INP | < 200ms | 200-500ms | > 500ms |
| CLS | < 0.1 | 0.1-0.25 | > 0.25 |
| TTFB | < 800ms | 800ms-1.8s | > 1.8s |
<!-- Hero/LCP image: eager + high priority -->
<img src="/hero.webp" alt="Hero" width="1200" height="600" loading="eager" fetchpriority="high" decoding="async" />
<!-- Below fold: lazy load -->
<img src="/product.webp" alt="Product" width="400" height="300" loading="lazy" decoding="async" />
Always set width and height to prevent CLS.
<!-- Preconnect to font origin -->
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<!-- Non-blocking font load -->
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter&display=swap"
media="print"
onload="this.media='all'"
/>
<!-- Defer to user interaction -->
<script>
function loadThirdParty() {
// Load analytics, chat widgets, etc.
}
;['scroll', 'click', 'touchstart'].forEach((e) => addEventListener(e, loadThirdParty, { once: true, passive: true }))
setTimeout(loadThirdParty, 5000)
</script>
Inline critical CSS in <head>, defer the rest:
<style>
/* critical styles */
</style>
<link rel="preload" href="/styles.css" as="style" onload="this.rel='stylesheet'" />
# Webpack
npx webpack-bundle-analyzer dist/stats.json
# Vite
npx vite-bundle-visualizer
# Check package size before installing
npx bundlephobia <package-name>
Common heavy packages to replace:
moment (67KB) → date-fns (12KB) or dayjs (2KB)lodash (72KB) → cherry-pick imports or native methods// React lazy
const Chart = lazy(() => import('./Chart'))
// Next.js dynamic
const Admin = dynamic(() => import('./Admin'), { ssr: false })
// Vite/Rollup manual chunks
build: {
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom']
}
}
}
}
# Static assets (immutable hash in filename)
Cache-Control: public, max-age=31536000, immutable
# HTML (revalidate)
Cache-Control: no-cache
# API responses
Cache-Control: private, max-age=0, must-revalidate
For running audits, reading reports, and setting budgets, use the perf-lighthouse skill.
srcsetwidth/height attributesloading="lazy" below foldfetchpriority="high" on LCP imagefont-display: swapFor in-depth optimization patterns, see:
Weekly Installs
67
Repository
GitHub Stars
1.9K
First Seen
Feb 5, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode66
gemini-cli64
codex64
github-copilot64
amp62
kimi-cli62
GSAP React 动画库使用指南:useGSAP Hook 与最佳实践
3,500 周安装
LobeHub桌面端开发指南:基于Electron的桌面应用架构与功能实现教程
556 周安装
Elasticsearch专家指导:搜索优化、ELK栈部署与分布式系统实战
62 周安装
Render 部署指南:Git 驱动与 Docker 镜像部署全解析
553 周安装
PyTorch深度学习开发专家 | Transformer、扩散模型、LLM开发指南与最佳实践
545 周安装
Rust最佳实践指南:179条规则提升代码质量与性能 | 所有权、错误处理、内存优化
551 周安装
TypeORM 开发指南:TypeScript ORM 框架实战教程与数据库设计
554 周安装