跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 performance

Performance

优化网络性能以更快地加载和更好的用户体验. 当被要求"加快我的站点","优化性能","减少负载时间","固定慢装","改进页面速度",或"绩效审核"时使用.

43463 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

优化网络性能以更快地加载和更好的用户体验

何时用

要求"加快我的站点","优化性能","减少负载时间","固定慢装","改进页面速度",或"绩效审计"

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Performance optimization、How it works、Starting performance budget、Critical rendering path、Server response、Resource loading。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/MEASUREMENT.md、references/RUM.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".

Performance optimizationHow it worksStarting performance budgetCritical rendering pathServer responseResource loadingJavaScript optimizationImage optimizationFormat selectionResponsive imagesLCP image priorityFont optimization

· 许可:MIT

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
performance
description
Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".
许可
MIT
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 2
  • references/MEASUREMENT.md
  • references/RUM.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「performance」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-209aa90a3a3a3461-%E4%B8%9A%E7%BB%A9.html
请存为 .cursor/skills/performance/SKILL.md 或 .claude/skills/performance/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/addyosmani/web-quality-skills 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/addyosmani/web-quality-skills' --list

npx skills add 'https://github.com/addyosmani/web-quality-skills' --skill 'performance'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: performance description: Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit". license: MIT metadata: author: web-quality-skills version: "2.0" --- # Performance optimization Evidence-led performance optimization using real-user signals for prioritization and browser traces for diagnosis. Focuses on loading speed, runtime responsiveness, and resource delivery. ## How it works 1. If a page can run, read [the measurement workflow](references/MEASUREMENT.md) and establish a field-plus-lab baseline before editing. 2. Prioritize poor real-user Core Web Vitals. Use a DevTools performance trace and its focused insights to find the cause. 3. Inspect and change only the code or assets connected to measured bottlenecks. 4. Re-run equivalent lab measurements and report before/after values, conditions, and uncertainty. Field verification remains pending until enough new user data arrives. When no runnable page exists, perform static inspection but call findings **hypotheses**, not measured regressions. Include the command or browser workflow that can verify each high-impact hypothesis. Prefer a browser tool that records a performance trace and exposes focused insights. With Chrome DevTools MCP, use `performance_start_trace` and `performance_analyze_insight`; do not route performance through `lighthouse_audit`, which covers non-performance Lighthouse categories. ## Starting performance budget Budgets must reflect the product's target devices, networks, page types, and user journeys. The values below are initial guardrails for a typical content or commerce page, not universal pass/fail criteria. Preserve an existing project budget when one is already defined. | Resource | Budget | Rationale | |----------|--------|-----------| | Total page weight | < 1.5 MB | Bounds transfer time and data cost on constrained target networks; calibrate with representative pages | | JavaScript (compressed) | < 300 KB | Protect parse and execution cost | | CSS (compressed) | < 100 KB | Limit render-blocking work | | Images (above-fold) | < 500 KB | Protect likely LCP resources | | Fonts | < 100 KB | Limit critical font transfer | | Third-party | < 200 KB | Bound code outside product control | ## Critical rendering path ### Server response * **TTFB < 800ms.** Time to First Byte should be fast. Use CDN, caching, and efficient backends. * **Enable compression.** Gzip or Brotli for text assets. Brotli preferred (15-20% smaller). * **HTTP/2 or HTTP/3.** Multiplexing reduces connection overhead. * **Edge caching.** Cache HTML at CDN edge when possible. * **Consider Early Hints (HTTP 103) for measured document latency.** If a trace shows slow HTML generation and stable critical subresources, send an interim `103` with `Link` headers before the normal final response from the same request. Use HTTP/2 or later. A CDN may synthesize the `103` from `Link` headers on an earlier `200`, or the origin/edge handler can emit it directly. Unsupported clients continue to the final response, but confirm current browser and infrastructure support. Limit hints to proven critical preloads or preconnects: inaccurate hints waste bandwidth. Cloudflare reported a 20–30% LCP improvement in an artificial, image-heavy test; treat that as a vendor case study, not an expected saving, and measure your result. See [MDN's 103 implementation example](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103) and [the Cloudflare study](https://blog.cloudflare.com/early-hints-performance/). ### Resource loading **Preconnect to required origins:** ```html ``` **Preload critical resources:** Preload only resources whose late discovery is visible in the trace. Each preload competes for bandwidth and an unnecessary high-priority request can delay LCP. ```html ``` **Prerender likely-next navigations** with the [Speculation Rules API](https://developer.chrome.com/docs/web-platform/prerender-pages): ```html ``` `moderate` waits for a stronger intent signal than eager modes. Measure prediction hit rate, transferred bytes, and server cost; a wrong prerender is roughly an unused navigation. See [core-web-vitals → LCP](../core-web-vitals/SKILL.md#lcp-largest-contentful-paint) for the tradeoffs and the `prerenderingchange` gating needed for analytics. **Defer non-critical CSS:** ```html ``` ### JavaScript optimization **Defer non-essential scripts:** ```html ``` **Code splitting patterns:** ```javascript // Route-based splitting const Dashboard = lazy(() => import('./Dashboard')); // Component-based splitting const HeavyChart = lazy(() => import('./HeavyChart')); // Feature-based splitting if (user.isPremium) { const PremiumFeatures = await import('./PremiumFeatures'); } ``` **Tree shaking best practices:** ```javascript // ❌ Imports entire library import _ from 'lodash'; _.debounce(fn, 300); // ✅ Imports only what's needed import debounce from 'lodash/debounce'; debounce(fn, 300); ``` ## Image optimization ### Format selection | Format | Use case | Browser support | |--------|----------|-----------------| | AVIF | Photos, best compression | 92%+ | | WebP | Photos, good fallback | 97%+ | | PNG | Graphics with transparency | Universal | | SVG | Icons, logos, illustrations | Universal | ### Responsive images ```html ``` ### LCP image priority ```html ``` ## Font optimization ### Loading strategy ```css /* System font stack as fallback */ body { font-family: 'Custom Font', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; } /* Prevent invisible text */ @font-face { font-family: 'Custom Font'; src: url('/fonts/custom.woff2') format('woff2'); font-display: swap; /* or optional for non-critical */ font-weight: 400; font-style: normal; unicode-range: U+0000-00FF; /* Subset to Latin */ } ``` ### Preloading critical fonts ```html ``` ### Variable fonts ```css /* One file instead of multiple weights */ @font-face { font-family: 'Inter'; src: url('/fonts/Inter-Variable.woff2') format('woff2-variations'); font-weight: 100 900; font-display: swap; } ``` ## Caching strategy ### Cache-Control headers ``` # HTML (short or no cache) Cache-Control: no-cache, must-revalidate # Static assets with hash (immutable) Cache-Control: public, max-age=31536000, immutable # Static assets without hash Cache-Control: public, max-age=86400, stale-while-revalidate=604800 # API responses Cache-Control: private, max-age=0, must-revalidate ``` ### Service worker caching ```javascript // Cache-first for static assets self.addEventListener('fetch', (event) => { if (event.request.destination === 'image' || event.request.destination === 'style' || event.request.destination === 'script') { event.respondWith( caches.match(event.request).then((cached) => { return cached || fetch(event.request).then((response) => { const clone = response.clone(); caches.open('static-v1').then((cache) => cache.put(event.request, clone)); return response; }); }) ); } }); ``` ## Runtime performance ### Avoid layout thrashing ```javascript // ❌ Forces multiple reflows elements.forEach(el => { const height = el.offsetHeight; // Read el.style.height = height + 10 + 'px'; // Write }); // ✅ Batch reads, then batch writes const heights = elements.map(el => el.offsetHeight); // All reads elements.forEach((el, i) => { el.style.height = heights[i] + 10 + 'px'; // All writes }); ``` ### Debounce expensive operations ```javascript function debounce(fn, delay) { let timeout; return (...args) => { clearTimeout(timeout); timeout = setTimeout(() => fn(...args), delay); }; } // Debounce scroll/resize handlers window.addEventListener('scroll', debounce(handleScroll, 100)); ``` ### Use requestAnimationFrame ```javascript // ❌ May cause jank setInterval(animate, 16); // ✅ Synced with display refresh function animate() { // Animation logic requestAnimationFrame(animate); } requestAnimationFrame(animate); ``` ### Virtualize long lists ```javascript // For lists > 100 items, render only visible items // Use libraries like react-window, vue-virtual-scroller, or native CSS: .virtual-list { content-visibility: auto; contain-intrinsic-size: 0 50px; /* Estimated item height */ } ``` ### Smooth navigations with View Transitions The [View Transitions API](https://developer.chrome.com/docs/web-platform/view-transitions) lets the browser cross-fade (or custom-animate) between two DOM states using a single GPU-composited snapshot — no double-render, no layout thrash, and the snapshot doesn't count toward CLS. **Same-document (SPA-style) — Baseline 2026:** ```javascript // Wrap the DOM mutation that swaps the view function navigate(newView) { if (!document.startViewTransition) return swapDOM(newView); document.startViewTransition(() => swapDOM(newView)); } ``` **Cross-document (MPA-style) — Chromium-stable, progressive enhancement elsewhere:** ```css /* On both source and destination pages */ @view-transition { navigation: auto; } ``` That's the entire integration — same-origin navigations now fade automatically. To opt specific elements into shared-element transitions (e.g. a thumbnail expanding into a hero), give them a matching `view-transition-name`: ```css .product-thumb[data-id="42"], .product-hero { view-transition-name: product-42; } ``` Pair this with Speculation Rules (above) for instant + animated navigations. ## Third-party scripts ### Load strategies ```javascript // ❌ Blocks main thread // ✅ Async loading // ✅ Delay until interaction ``` ### Facade pattern ```html
▶
``` ## Measurement Use [the measurement workflow](references/MEASUREMENT.md) whenever a URL is runnable. It defines Chrome DevTools MCP routing, CrUX and fallback sources, repeatable lab conditions, and a compact evidence format. | Metric | Kind | Interpretation | |--------|------|----------------| | LCP, INP, CLS at p75 | Field | User-outcome Core Web Vitals; use for pass/fail prioritization | | LCP, CLS in a trace | Lab | Reproducible diagnostic values for one navigation | | TBT | Lab | Main-thread blocking diagnostic and a rough INP proxy, not field INP | | FCP, Speed Index | Lab | Loading diagnostics, not Core Web Vitals | Raw `PerformanceObserver` snippets are useful for the current browser session but are not real-user data by themselves. When the user wants production telemetry, read [the first-party RUM reference](references/RUM.md) and prefer `web-vitals` over a hand-rolled metric implementation. ## References For Core Web Vitals specific optimizations, see [Core Web Vitals](../core-web-vitals/SKILL.md).

相关技能

Agent 工作流

Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…