web-performance-web-performance
ウェブサイトの表示速度を改善するために、ファイルサイズを小さくしたり、表示の仕組みを最適化したり、主要な指標を改善したりすることで、ユーザー体験を高めるSkill。
📜 元の英語説明(参考)
Bundle optimization, render performance, Core Web Vitals
🇯🇵 日本人クリエイター向け解説
ウェブサイトの表示速度を改善するために、ファイルサイズを小さくしたり、表示の仕組みを最適化したり、主要な指標を改善したりすることで、ユーザー体験を高めるSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o web-performance-web-performance.zip https://jpskill.com/download/10298.zip && unzip -o web-performance-web-performance.zip && rm web-performance-web-performance.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10298.zip -OutFile "$d\web-performance-web-performance.zip"; Expand-Archive "$d\web-performance-web-performance.zip" -DestinationPath $d -Force; ri "$d\web-performance-web-performance.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
web-performance-web-performance.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
web-performance-web-performanceフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Web Performance Patterns
簡単なガイド: バンドル予算: gzip圧縮されたメインバンドルは200KB未満。Core Web Vitals: LCP < 2.5秒、INP < 200ms、CLS < 0.1。最適化の前にプロファイルしてください -- 実際のボトルネックを測定し、推測しないでください。ルートと重いライブラリを遅延ロードしてください。自動メモ化にはReact Compiler (React 19+)を使用してください。手動メモ化は、プロファイルによってボトルネックが証明された場合にのみ行ってください。Lighthouseだけでなく、
web-vitalsライブラリで実際のユーザーを監視してください。
<critical_requirements>
必須: パフォーマンス最適化の前に
(最適化の前に必ずプロファイルしてください - ブラウザのDevTools、フレームワークプロファイラ、またはLighthouseで実際のボトルネックを測定してください)
(機能を構築する前に必ずパフォーマンス予算を設定してください - バンドルサイズの制限とCore Web Vitalsの目標)
(すべてのパフォーマンス閾値に必ず名前付き定数を使用してください - 200や2.5のようなマジックナンバーは使用しないでください)
(本番環境で必ずCore Web Vitalsを監視してください - ラボのメトリクスだけでなく、実際のユーザーのLCP、INP、CLSを追跡してください)
(ルートコンポーネントと重いライブラリを必ず遅延ロードしてください - コード分割によって大きな初期バンドルを防ぎます)
</critical_requirements>
自動検出: Core Web Vitals、バンドルサイズ最適化、LCP、INP、CLS、遅延ロード、コード分割、メモ化、React Compiler、パフォーマンス監視、web-vitalsライブラリ、バンドル予算、仮想化、react-window、TanStack Virtual
使用する場面:
- Core Web Vitalsの最適化 (LCP < 2.5秒、INP < 200ms、CLS < 0.1)
- バンドルサイズの予算の設定と強制 (< 200KBのメインバンドル)
- ランタイムパフォーマンスパターンの実装 (戦略的なメモ化、遅延ロード、仮想化)
- 本番環境での
web-vitalsライブラリによるパフォーマンスの監視 - 初期バンドルを削減するためのコード分割とツリーシェイキング
使用しない場面:
- 測定前 (時期尚早な最適化は、メリットなしに複雑さを増します)
- 単純なコンポーネント (安価なレンダリングをメモ化するとオーバーヘッドが増えます)
- 10人未満の内部管理ツール (ROIが低すぎます)
- プロトタイプとMVP (プロダクトマーケットフィットを検証した後に最適化してください)
カバーする主要なパターン:
- Core Web Vitalsの目標と改善戦略 (LCP、INP、CLS)
- バンドルサイズの予算 (< 200KBのメイン、< 500KBの合計初期ロード)
- 戦略的なメモ化 (最初にプロファイルしてください。React Compilerがほとんどの場合を処理します)
- コード分割 (ルートベースの遅延ロード、動的インポート、ツリーシェイキング)
- 画像の最適化 (最新の形式、遅延ロード、レスポンシブ画像)
詳細なリソース:
- examples/core.md - Reactのメモ化、仮想スクロール、デバウンス
- examples/code-splitting.md - 遅延ロード、ツリーシェイキング、バンドル予算
- examples/web-vitals.md - LCP、INP、CLSのパターンと監視
- examples/image-optimization.md - 画像形式、遅延ロード、レスポンシブ画像
- reference.md - 意思決定フレームワークとアンチパターン
<philosophy>
哲学
パフォーマンスは後付けではなく、機能です。高速なアプリケーションは、ユーザーエクスペリエンス、コンバージョン率、およびSEOランキングを向上させます。パフォーマンスの最適化には、行動前の測定、構築前の予算、および本番環境での監視が必要です。
コア原則:
- 最初に測定し、次に最適化する - 実際のボトルネックをプロファイルし、推測しないでください
- 早期に予算を設定する - 構築前にバンドルサイズの制限とCore Web Vitalsの目標を定義します
- 実際のユーザーを監視する - ラボのメトリクス (Lighthouse) は、実際のパフォーマンス (RUM) とは異なります
- 戦略的に最適化する - 高価な操作をメモ化し、すべてをメモ化しないでください
- デフォルトで遅延ロードする - 必要なときにコードをロードし、事前にロードしないでください
</philosophy>
<patterns>
コアパターン
パターン1: バンドルサイズの予算
バンドルサイズの制限を設定して強制し、肥大化を防ぎます。メインバンドルは、3Gネットワークでの高速ダウンロードのために、gzip圧縮で200KB未満にする必要があります。
// constants/bundle-budgets.ts
export const BUNDLE_SIZE_BUDGETS_KB = {
MAIN_BUNDLE_GZIPPED: 200,
VENDOR_BUNDLE_GZIPPED: 150,
ROUTE_BUNDLE_GZIPPED: 100,
TOTAL_INITIAL_LOAD_GZIPPED: 500,
MAIN_CSS_GZIPPED: 50,
CRITICAL_CSS_INLINE: 14, // 最初のTCPパケットに収まる
} as const;
これらの制限の理由: 200 KB ≈ 3Gで1秒のダウンロード、より高速なTime to Interactive (TTI)、より優れたモバイルパフォーマンス
推奨される予算:
- メインバンドル: gzip圧縮で< 200 KB
- ベンダーバンドル: gzip圧縮で< 150 KB
- ルートバンドル: gzip圧縮でそれぞれ< 100 KB
- 合計初期ロード: gzip圧縮で< 500 KB
- メインCSS: gzip圧縮で< 50 KB
- クリティカルCSS: インラインで< 14 KB (最初のTCPパケットに収まる)
強制の例については、examples/code-splitting.mdを参照してください。
パターン2: Core Web Vitalsの最適化
GoogleのCore Web Vitals (LCP < 2.5秒、INP < 200ms、CLS < 0.1) に最適化します。これらのメトリクスは、SEOとユーザーエクスペリエンスに影響を与えます。
// constants/web-vitals.ts
export const CORE_WEB_VITALS_THRESHOLDS = {
LCP_SECONDS: 2.5, // Largest Contentful Paint
INP_MS: 200, // Interaction to Next Paint
CLS_SCORE: 0.1, // Cumulative Layout Shift
FCP_SECONDS: 1.8, // First Contentful Paint
TTI_SECONDS: 3.8, // Time to Interactive
TBT_MS: 300, // Total Blocking Time
TTFB_MS: 800, // Time to First Byte
} as const;
LCP (Largest Contentful Paint): < 2.5秒
読み込みパフォーマンスを測定します -- 最大の可視要素がレンダリングされるタイミング。
改善方法: 画像を最適化し (最新の形式、ヒーロー画像をプリロード)、レンダリングをブロックするリソースを最小限に抑え、静的アセットにCDNを使用し、重要なコンテンツにSSRまたはSSGを使用します。
INP (Interaction to Next Paint): < 200ms
すべてのユーザーインタラクションにわたるインタラクティビティを測定します (2024年3月にFIDに代わりました)。入力遅延、処理時間、およびプレゼンテーション遅延が含まれます。
改善方法: JavaScriptの実行時間を最小限に抑え、コードを分割して事前にロードするJSを減らし、重い計算にWebワーカーを使用し、scheduler.yield()またはsetTimeoutを使用して長いタスク (> 50ms) を分割します。
CLS (Cumulative Layout Shift): < 0.1
視覚的な安定性を測定します -- 予期しないレイアウトシフトを防ぎます。
改善方法: 明示的に
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Web Performance Patterns
Quick Guide: Bundle budgets: < 200KB main bundle gzipped. Core Web Vitals: LCP < 2.5s, INP < 200ms, CLS < 0.1. Profile before optimizing -- measure actual bottlenecks, don't guess. Lazy load routes and heavy libraries. Use React Compiler (React 19+) for automatic memoization; manual memo only when profiling proves a bottleneck. Monitor real users with web-vitals library, not just Lighthouse.
<critical_requirements>
CRITICAL: Before Optimizing Performance
(You MUST profile BEFORE optimizing - measure actual bottlenecks with browser DevTools, framework profiler, or Lighthouse)
(You MUST set performance budgets BEFORE building features - bundle size limits and Core Web Vitals targets)
(You MUST use named constants for ALL performance thresholds - no magic numbers like 200 or 2.5)
(You MUST monitor Core Web Vitals in production - track LCP, INP, CLS for real users, not just lab metrics)
(You MUST lazy load route components and heavy libraries - code splitting prevents large initial bundles)
</critical_requirements>
Auto-detection: Core Web Vitals, bundle size optimization, LCP, INP, CLS, lazy loading, code splitting, memoization, React Compiler, performance monitoring, web-vitals library, bundle budget, virtualization, react-window, TanStack Virtual
When to use:
- Optimizing Core Web Vitals (LCP < 2.5s, INP < 200ms, CLS < 0.1)
- Setting and enforcing bundle size budgets (< 200KB main bundle)
- Implementing runtime performance patterns (strategic memo, lazy loading, virtualization)
- Monitoring performance with web-vitals library in production
- Code splitting and tree shaking to reduce initial bundle
When NOT to use:
- Before measuring (premature optimization adds complexity without benefit)
- For simple components (memoizing cheap renders adds overhead)
- Internal admin tools with < 10 users (ROI too low)
- Prototypes and MVPs (optimize after validating product-market fit)
Key patterns covered:
- Core Web Vitals targets and improvement strategies (LCP, INP, CLS)
- Bundle size budgets (< 200KB main, < 500KB total initial load)
- Strategic memoization (profile first; React Compiler handles most cases)
- Code splitting (route-based lazy loading, dynamic imports, tree shaking)
- Image optimization (modern formats, lazy loading, responsive images)
Detailed Resources:
- examples/core.md - React memoization, virtual scrolling, debouncing
- examples/code-splitting.md - Lazy loading, tree shaking, bundle budgets
- examples/web-vitals.md - LCP, INP, CLS patterns and monitoring
- examples/image-optimization.md - Image formats, lazy loading, responsive images
- reference.md - Decision frameworks and anti-patterns
<philosophy>
Philosophy
Performance is a feature, not an afterthought. Fast applications improve user experience, conversion rates, and SEO rankings. Performance optimization requires measurement before action, budgets before building, and monitoring in production.
Core principles:
- Measure first, optimize second - Profile actual bottlenecks, don't guess
- Set budgets early - Define bundle size limits and Core Web Vitals targets before building
- Monitor real users - Lab metrics (Lighthouse) differ from real-world performance (RUM)
- Optimize strategically - Memoize expensive operations, not everything
- Lazy load by default - Load code when needed, not upfront
</philosophy>
<patterns>
Core Patterns
Pattern 1: Bundle Size Budgets
Set and enforce bundle size limits to prevent bloat. Main bundle should be < 200KB gzipped for fast downloads on 3G networks.
// constants/bundle-budgets.ts
export const BUNDLE_SIZE_BUDGETS_KB = {
MAIN_BUNDLE_GZIPPED: 200,
VENDOR_BUNDLE_GZIPPED: 150,
ROUTE_BUNDLE_GZIPPED: 100,
TOTAL_INITIAL_LOAD_GZIPPED: 500,
MAIN_CSS_GZIPPED: 50,
CRITICAL_CSS_INLINE: 14, // Fits in first TCP packet
} as const;
Why these limits: 200 KB ≈ 1 second download on 3G, faster Time to Interactive (TTI), better mobile performance
Recommended budgets:
- Main bundle: < 200 KB gzipped
- Vendor bundle: < 150 KB gzipped
- Route bundles: < 100 KB each gzipped
- Total initial load: < 500 KB gzipped
- Main CSS: < 50 KB gzipped
- Critical CSS: < 14 KB inlined (fits in first TCP packet)
For enforcement examples, see examples/code-splitting.md.
Pattern 2: Core Web Vitals Optimization
Optimize for Google's Core Web Vitals: LCP < 2.5s, INP < 200ms, CLS < 0.1. These metrics impact SEO and user experience.
// constants/web-vitals.ts
export const CORE_WEB_VITALS_THRESHOLDS = {
LCP_SECONDS: 2.5, // Largest Contentful Paint
INP_MS: 200, // Interaction to Next Paint
CLS_SCORE: 0.1, // Cumulative Layout Shift
FCP_SECONDS: 1.8, // First Contentful Paint
TTI_SECONDS: 3.8, // Time to Interactive
TBT_MS: 300, // Total Blocking Time
TTFB_MS: 800, // Time to First Byte
} as const;
LCP (Largest Contentful Paint): < 2.5s
Measures loading performance -- when the largest visible element renders.
How to improve: Optimize images (modern formats, preload hero images), minimize render-blocking resources, use CDN for static assets, SSR or SSG for critical content.
INP (Interaction to Next Paint): < 200ms
Measures interactivity across ALL user interactions (replaced FID in March 2024). Includes input delay, processing time, and presentation delay.
How to improve: Minimize JavaScript execution time, code split to load less JS upfront, use web workers for heavy computation, break up long tasks (> 50ms) with scheduler.yield() or setTimeout.
CLS (Cumulative Layout Shift): < 0.1
Measures visual stability -- prevents unexpected layout shifts.
How to improve: Set explicit image/video dimensions, reserve space for dynamic content (ads, embeds), avoid injecting content above existing content, use font-display: swap with size-adjust.
For detailed examples and monitoring setup, see examples/web-vitals.md.
Pattern 3: Code Splitting and Lazy Loading
Lazy load route components and heavy libraries. Code splitting keeps the initial bundle small by loading code on demand.
import { lazy, Suspense } from 'react';
// Route-based splitting - each route is a separate chunk
const Dashboard = lazy(() => import('./pages/dashboard'));
const Reports = lazy(() => import('./pages/reports'));
export function App() {
return (
<Suspense fallback={<PageLoader />}>
<Routes>
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/reports" element={<Reports />} />
</Routes>
</Suspense>
);
}
Why good: Splits bundle by route, loads components on demand, users only download what they navigate to
When to lazy load: Route components, heavy feature modules, modals/dialogs, below-fold content
When NOT to lazy load: Above-fold components, error boundaries, loading states
For tree shaking and bundle enforcement, see examples/code-splitting.md.
Pattern 4: Strategic Memoization
Profile before memoizing. React Compiler (v1.0, Oct 2025) auto-memoizes in most cases. Manual memo only when profiling proves a bottleneck.
// Only memoize when profiling shows > 5ms render time
const EXPENSIVE_RENDER_MS = 5;
// ✅ Expensive calculation with large dataset
const sortedRows = useMemo(
() => [...rows].sort((a, b) => compareValues(a[sortColumn], b[sortColumn])),
[rows, sortColumn],
);
// ❌ Trivial calculation - memo overhead exceeds cost
const doubled = useMemo(() => value * 2, [value]);
React Compiler (React 19+): Automatically memoizes components, values, and functions at build time. Manual useMemo/useCallback/React.memo rarely needed. Only add manual memo for: third-party interop, non-pure computations, or when profiling shows the compiler missed an optimization.
For complete memoization patterns, see examples/core.md.
</patterns>
<red_flags>
RED FLAGS
High Priority Issues:
- No performance budgets defined -- bundle sizes grow unnoticed, Core Web Vitals degrade
- Memoizing everything without profiling -- adds overhead, increases complexity, premature optimization
- Not lazy loading routes -- massive initial bundles, slow Time to Interactive
- Importing entire libraries (
import _ from 'lodash') -- bundles unused code, prevents tree shaking - Not optimizing images -- images are 50%+ of page weight; modern formats reduce size 30-50%
- Blocking main thread with heavy computation -- causes high INP, use web workers or break up long tasks
Medium Priority Issues:
- Not monitoring Core Web Vitals in production -- lab metrics differ from real users
- Rendering 100+ items without virtualization -- DOM bloat, slow scrolling
- No bundle size enforcement in CI -- regressions slip through code review
- Using CommonJS imports (
require()) -- prevents tree shaking
Gotchas & Edge Cases:
React.memouses shallow comparison -- deep object props always trigger re-renderuseMemo/useCallbackhave overhead -- only use for expensive operations (> 5ms)- React Compiler (v1.0) handles memoization automatically -- manual memo is rarely needed
- Lighthouse scores differ from real users -- always monitor RUM with web-vitals
- Code splitting increases total bundle size slightly (runtime overhead) -- net win for initial load
- Virtual scrolling breaks browser find-in-page (Cmd+F)
- Lazy loading doesn't work in SSR -- components load on client mount
- AVIF support is ~95% (2026) -- always provide WebP fallbacks
- Bundle size budgets should account for gzip/brotli compression
</red_flags>
<critical_reminders>
CRITICAL REMINDERS
(You MUST profile BEFORE optimizing - measure actual bottlenecks with browser DevTools, framework profiler, or Lighthouse)
(You MUST set performance budgets BEFORE building features - bundle size limits and Core Web Vitals targets)
(You MUST use named constants for ALL performance thresholds - no magic numbers like 200 or 2.5)
(You MUST monitor Core Web Vitals in production - track LCP, INP, CLS for real users, not just lab metrics)
(You MUST lazy load route components and heavy libraries - code splitting prevents large initial bundles)
Failure to follow these rules will result in slow applications, poor Core Web Vitals, large bundles, and degraded user experience.
</critical_reminders>