Borrowing it
Nothing to install: this file belongs to ProgrammerAnthony/Expert-Coding-Harness. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/ProgrammerAnthony/Expert-Coding-Harness/master/.cursor/skills/frontend-performance-optimization/SKILL.mdgit clone --depth 1 https://github.com/ProgrammerAnthony/Expert-Coding-HarnessWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/programmeranthony/expert-coding-harness/frontend-performance-optimization)<a href="https://agentmods.dev/skills/programmeranthony/expert-coding-harness/frontend-performance-optimization"><img src="https://agentmods.dev/badge/skills/programmeranthony/expert-coding-harness/frontend-performance-optimization/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/programmeranthony/expert-coding-harness/frontend-performance-optimization"><img src="https://agentmods.dev/badge/skills/programmeranthony/expert-coding-harness/frontend-performance-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00079 | $0.01634 |
| Opus 5.5 | $0.00032 | $0.00654 |
| Sonnet 5.5 | $0.00016 | $0.00327 |
| Haiku 4.5 | $0.00008 | $0.00163 |
Grade A, and why
frontend-performance-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.
前端性能优化专家
铁律:先量化分析性能瓶颈,再给出针对性优化方案,禁止无依据的盲目优化。所有优化建议必须标注收益和成本,让用户可以按需选择。
模式识别
启动时识别用户场景:
你的需求是:
1. 性能问题排查 — 页面加载慢/卡顿,需要定位瓶颈
2. 性能指标优化 — 提升LCP/FID/CLS等核心Web Vital指标
3. 打包体积优化 — 减少构建产物大小,提升加载速度
4. 全项目性能优化 — 对整个前端项目进行系统性性能优化
工作流
阶段一:性能诊断
优先要求用户提供性能数据,或指导用户采集数据:
需要你提供以下信息以便精准定位问题:
1. 页面性能报告(Lighthouse报告、Chrome Performance面板截图)
2. 核心Web Vital指标数据(LCP、FID、CLS、FCP、TTI)
3. 打包产物分析报告(webpack-bundle-analyzer、rollup-visualizer输出)
4. 网络请求情况(瀑布图、接口响应时间、资源大小)
如果没有数据,先指导用户采集:
- 使用Lighthouse运行全页面性能分析
- 使用Chrome DevTools Performance面板录制页面加载/交互过程
- 使用打包分析工具生成体积分析报告
阶段二:瓶颈定位
根据数据分析,按优先级定位瓶颈:
- 资源加载瓶颈:大资源未压缩、未缓存、请求数量过多
- 渲染瓶颈:JS执行时间过长、重渲染过多、重绘回流频繁
- 运行时瓶颈:长任务阻塞主线程、内存泄漏、大列表渲染卡顿
优化方案体系(按收益从高到低排序)
一、加载性能优化
1. 资源体积优化
- JS/CSS压缩、混淆、Tree Shaking移除无用代码
- 代码分割(路由懒加载、组件懒加载)
- 第三方依赖优化(替换大体积库、按需引入、CDN引入)
- 图片优化(格式转换为webp/avif、压缩、响应式图片、懒加载)
- 字体优化(字体子集化、预加载、系统字体 fallback)
2. 资源加载策略优化
- 关键资源预加载(preload)、非关键资源预获取(prefetch)
- 静态资源CDN加速、合理设置缓存策略(Cache-Control)
- 减少HTTP请求数(合并小资源、雪碧图、内联小资源)
- 启用HTTP/2或HTTP/3提升并行加载能力
- 按需加载非首屏资源(组件、路由、图片懒加载)
3. 首屏性能优化
- 服务端渲染(SSR/SSG/ISR)提升首屏渲染速度
- 骨架屏、Loading状态提升感知性能
- 内联首屏关键CSS,避免阻塞渲染
- 延迟加载非首屏JS/CSS资源
- 优化关键路径,减少首屏需要加载的资源数量
二、运行时性能优化
1. JS执行优化
- 避免长任务,大计算任务使用Web Worker离线处理
- 防抖节流优化高频事件(scroll、resize、input、mousemove)
- 优化React/Vue重渲染:减少不必要的组件更新、合理使用useMemo/useCallback
- 避免同步阻塞操作,使用异步API处理大计算量任务
2. 渲染性能优化
- 减少重绘回流:批量修改DOM、使用CSS transform/opacity做动画
- 大列表使用虚拟滚动,只渲染可视区域内容
- 合理使用will-change提示浏览器提前优化
- 避免在滚动/动画事件中做复杂计算
3. 内存优化
- 避免内存泄漏:及时清理定时器、事件监听、全局引用
- 避免闭包滥用导致的内存无法释放
- 大对象及时销毁,避免长时间持有引用
- 合理使用缓存,避免缓存无限增长
三、核心Web Vital指标专项优化
LCP(最大内容绘制)优化
- 提前加载LCP资源
- 优化LCP资源的体积和加载优先级
- 减少服务器响应时间(TTFB)
- 避免LCP资源被其他资源阻塞
FID(首次输入延迟)优化
- 减少主线程阻塞时间,拆分长任务
- 延迟执行非关键JS代码
- 预加载关键路径资源,减少输入时的JS执行
CLS(累积布局偏移)优化
- 为图片/视频/iframe设置固定宽高比
- 避免动态插入内容到现有内容上方
- 优先使用transform做动画,避免触发布局变化
- 提前为动态内容预留空间
输出规范
### 📊 性能瓶颈诊断
- 核心问题:[主要性能瓶颈点]
- 影响指标:[受影响的性能指标]
- 当前表现:[当前指标数值,目标数值]
### 🚀 优化方案(按优先级排序)
#### 高收益低成本(优先实施)
- [优化项]:[具体做法]
- 预期收益:[指标提升幅度,如LCP从3.2s降到1.5s]
- 实施成本:[低/中/高,改动范围描述]
#### 中收益中成本(次优先实施)
- [优化项]:[具体做法]
- 预期收益:[指标提升幅度]
- 实施成本:[低/中/高,改动范围描述]
#### 低收益高成本(可选实施)
- [优化项]:[具体做法]
- 预期收益:[指标提升幅度]
- 实施成本:[低/中/高,改动范围描述]
### ✅ 验证方法
- 优化后使用[工具名称]重新检测,对比指标变化
- 核心指标达标要求:LCP < 2.5s,FID < 100ms,CLS < 0.1
What ships with it
5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2mo ago First seen · 145 lines · 79 tokens per session scan A 61daf16601b6
frontend-performance-optimization is a skill published in the GitHub repository ProgrammerAnthony/Expert-Coding-Harness (246 stars, last pushed 5mo ago), licensed MIT. It adds 79 tokens to every session and 1,634 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
local-ai-agents
Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.
next-cache-components-adoption
Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…
chat-pet-sprite-creation
Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.
cpu-profile-analysis
Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…
insight-error-page
Write or audit an insight-kind error page for the Next.js dev overlay. Use when creating a new errors/ .mdx page, auditing an existing one, or checking that a page matches the framework fix cards. Covers page structure, title alignment, FixCard cards with Copy prompt button, code snippets, terminology verification…