Community生產力與協作github.com

addyosmani/performance-optimization

優化應用程式效能。適用於存在效能需求時、懷疑有效能衰退時,或是需要改進 Core Web Vitals 或載入時間時。也適用於分析發現需要修復的瓶頸時。

performance-optimization 是什麼?

此技能專注於應用程式效能最佳化,協助開發者識別並解決效能瓶頸,進而改善使用者體驗。它能應對多種場景,例如 Core Web Vitals(LCP、FCP、CLS、INP)未達標、載入時間過長、或分析工具顯示效能衰退。此技能支援多種平台與框架(如 React、Next.js、Vue),並提供一系列最佳化策略,包括程式碼分割、資源壓縮、圖片最佳化、快取策略、以及伺服器端渲染(SSR)或靜態網站生成(SSG)的調整。透過自動化分析效能報告(如 Lighthouse)並產生具體建議,它能幫助開發者系統性地改善應用程式的整體效能。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/addyosmani/agent-skills/tree/main/skills/performance-optimization

Installed? Explore more 生產力與協作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

performance-optimization 是做什麼的?

優化應用程式效能。適用於存在效能需求時、懷疑有效能衰退時,或是需要改進 Core Web Vitals 或載入時間時。也適用於分析發現需要修復的瓶頸時。

使用時機

  • 當專案有明確的效能目標時(例如達到 Lighthouse 90 分以上)
  • 當使用者回報頁面載入緩慢或互動卡頓時
  • 當 Core Web Vitals 指標(LCP、FCP、CLS、INP)未達良好範圍時
  • 當使用分析工具(如 Chrome DevTools Performance、Lighthouse、WebPageTest)發現瓶頸時
  • 當進行程式碼審查,懷疑可能引入效能問題時

支援的平台

  • Web 應用程式:React、Next.js、Vue、Angular、Svelte 等主流框架
  • 行動端:React Native、Flutter(部分建議通用)
  • Node.js 後端:API 回應時間最佳化、資料庫查詢最佳化

主要最佳化策略

1. 載入效能

  • 程式碼分割:使用動態 import() 將大型套件拆分,減少初始載入量
  • 資源壓縮:啟用 Gzip 或 Brotli 壓縮,減少傳輸大小
  • 圖片最佳化:使用現代格式(WebP、AVIF)、響應式圖片、延遲載入(loading="lazy")
  • 快取策略:設定適當的 Cache-Control 標頭,使用 Service Worker 進行資源快取

2. 渲染效能

  • 減少重排與重繪:避免頻繁操作 DOM,使用 requestAnimationFrame 進行動畫
  • 虛擬列表:對長列表使用虛擬化技術(如 react-window、react-virtualized)
  • 避免不必要的重新渲染:使用 React.memo、useMemo、useCallback 進行記憶化

3. 網路效能

  • CDN 使用:將靜態資源部署至 CDN,減少延遲
  • 預先載入關鍵資源:使用 <link rel="preload"> 或 <link rel="preconnect">
  • HTTP/2 或 HTTP/3:確保伺服器支援,啟用多路複用

如何開始

  1. 執行 Lighthouse 審查,取得目前的效能分數與建議
  2. 根據建議優先處理影響最大的項目(如 Largest Contentful Paint)
  3. 使用 Chrome DevTools Performance 面板記錄並分析執行階段瓶頸
  4. 應用本技能提供的策略進行修復
  5. 重新測試以驗證改善幅度

注意事項

  • 效能最佳化應以使用者實際體驗為核心,避免過度最佳化
  • 在變更後應進行回歸測試,確保功能正常
  • 不同應用程式的瓶頸可能不同,請根據分析結果對症下藥

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

addyosmani/agent-skills

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

addyosmani/agent-skills

Prepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.

addyosmani/agent-skills

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

addyosmani/browser-testing-with-devtools

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

addyosmani/ci-cd-and-automation

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

addyosmani/code-review-and-quality

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch.

addyosmani/code-simplification

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

addyosmani/constraint-driven-development

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

addyosmani/debugging-and-error-recovery

Guides systematic root-cause debugging. Use when tests fail, builds break, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need a systematic approach to finding and fixing the root cause rather than guessing.

addyosmani/deprecation-and-migration

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.

addyosmani/documentation-and-adrs

Records decisions and documentation. Use when making architectural decisions, changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

addyosmani/doubt-driven-development

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production, security-sensitive logic, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

addyosmani/git-workflow-and-versioning

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.

addyosmani/idea-refine

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

addyosmani/incremental-implementation

Delivers changes incrementally. Use when implementing any feature or change that touches more than one file. Use when you're about to write a large amount of code at once, or when a task feels too big to land in one step.

addyosmani/interview-me

Extracts what the user actually wants instead of what they think they should want. Achieves this through one-question-at-a-time interview until ~95% confidence about the underlying intent. Use when an ask is underspecified ("build me X" without "for whom" or "why now"), when the user explicitly invokes ("interview me", "grill me", "are we sure?", "stress-test my thinking"), or when you catch yourself silently filling in ambiguous requirements before any plan, spec, or code exists.

addyosmani/observability-and-instrumentation

Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.

addyosmani/planning-and-task-breakdown

Breaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible.

addyosmani/security-and-hardening

Hardens code against vulnerabilities. Use when handling user input, authentication, data storage, or external integrations. Use when building any feature that accepts untrusted data, manages user sessions, or interacts with third-party services.

addyosmani/source-driven-development

Grounds every implementation decision in official documentation. Use when you want authoritative, source-cited code free from outdated patterns. Use when building with any framework or library where correctness matters.

相關技能