xiaohongshu
xiaohongshu
frontend-performance
フロントエンドパフォーマンス最適化ガイド。Core Web Vitals改善、バンドルサイズ削減、レンダリング最適化、画像最適化など、高速なWebアプリケーション構築のベストプラクティス。
Full skill instructions
このSkillは、フロントエンドパフォーマンス最適化をカバーします:
このガイドで学べること: Core Web Vitals改善、バンドル最適化、レンダリング戦略、画像最適化、キャッシング戦略 公式で確認すべきこと: 最新のパフォーマンス指標、ブラウザアップデート、フレームワーク最適化機能
web.dev Performance - Googleパフォーマンスガイド
Next.js Performance - Next.js最適化ガイド
Chrome DevTools - パフォーマンス分析ツール
WebPageTest Documentation - パフォーマンス測定
プロダクションレベルの最適化を学ぶには、以下の完全ガイドを参照してください:
30,000文字 | 実測値データ | 業界別ベンチマーク
26,000文字 | Code Splitting | 依存関係管理
27,000文字 | SSR・ISR | React最適化 | 仮想化
合計: 83,000文字 | 40以上の完全実装例 | 実プロジェクトの測定データ
| 指標 | 説明 | 目標 |
|---|---|---|
| LCP (Largest Contentful Paint) | 最大コンテンツの表示時間 | < 2.5秒 |
| FID (First Input Delay) | 初回入力遅延 | < 100ms |
| CLS (Cumulative Layout Shift) | レイアウトシフト | < 0.1 |
// Next.js App Router(デフォルトでSSR)
export default async function Page() {
const data = await fetch('https://api.example.com/data')
return <div>{/* content */}</div>
}
// Next.js Image(自動最適化)
import Image from 'next/image'
<Image
src="/hero.jpg"
alt="Hero"
width={1200}
height={600}
priority // Above the fold
/>
// next.config.js
module.exports = {
optimizeFonts: true,
}
// app/layout.tsx
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
export default function RootLayout({ children }) {
return (
<html lang="ja" className={inter.className}>
<body>{children}</body>
</html>
)
}
// 動的インポート
import dynamic from 'next/dynamic'
const HeavyComponent = dynamic(() => import('@/components/HeavyComponent'), {
loading: () => <p>Loading...</p>,
})
export default function Page() {
return <HeavyComponent />
}
// ❌ 悪い例(不要なライブラリ)
import moment from 'moment' // 288KB
// ✅ 良い例(軽量ライブラリ)
import { format } from 'date-fns' // 13KB
// ❌ 悪い例(サイズ未指定 → レイアウトシフト)
<img src="/image.jpg" alt="Image" />
// ✅ 良い例(サイズ指定)
<Image
src="/image.jpg"
alt="Image"
width={800}
height={600}
/>
/* ❌ 悪い例(フォント読み込み待ち → レイアウトシフト) */
@font-face {
font-family: 'CustomFont';
src: url('/fonts/custom.woff2');
font-display: block;
}
/* ✅ 良い例(フォールバックフォント表示) */
@font-face {
font-family: 'CustomFont';
src: url('/fonts/custom.woff2');
font-display: swap;
}
# Next.js バンドル分析
pnpm add -D @next/bundle-analyzer
# next.config.js
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer({
// ...
})
# 実行
ANALYZE=true pnpm build
// ❌ 悪い例(全体インポート)
import _ from 'lodash' // 全体がバンドルされる
// ✅ 良い例(個別インポート)
import debounce from 'lodash/debounce'
// または
import { debounce } from 'lodash-es' // ES Modules版
// ルートベース分割(Next.jsは自動)
app/
├── page.tsx # Bundle 1
├── about/page.tsx # Bundle 2
└── blog/page.tsx # Bundle 3
// コンポーネント分割
const Modal = dynamic(() => import('@/components/Modal'))
function Page() {
const [showModal, setShowModal] = useState(false)
return (
<>
<button onClick={() => setShowModal(true)}>Open</button>
{showModal && <Modal />} // 必要なときのみロード
</>
)
}
// Next.js(ビルド時に生成)
export default async function Page() {
const posts = await getPosts()
return <PostList posts={posts} />
}
// 静的パス生成
export async function generateStaticParams() {
const posts = await getPosts()
return posts.map(post => ({ slug: post.slug }))
}
// 60秒ごとに再生成
export const revalidate = 60
export default async function Page() {
const posts = await fetch('https://api.example.com/posts', {
next: { revalidate: 60 }
}).then(r => r.json())
return <PostList posts={posts} />
}
// React.memo
const ExpensiveComponent = React.memo(({ data }) => {
return <div>{/* ... */}</div>
})
// useMemo
function Component({ items }) {
const sortedItems = useMemo(() => {
return items.sort((a, b) => a.name.localeCompare(b.name))
}, [items])
return <List items={sortedItems} />
}
// useCallback
function Parent() {
const handleClick = useCallback(() => {
console.log('clicked')
}, [])
return <Child onClick={handleClick} />
}
import Image from 'next/image'
// ✅ 自動最適化
<Image
src="/images/hero.jpg"
alt="Hero"
width={1200}
height={600}
quality={75} // デフォルト75
priority // Above the fold
/>
// ✅ レスポンシブ画像
<Image
src="/images/hero.jpg"
alt="Hero"
fill
style={{ objectFit: 'cover' }}
sizes="(max-width: 768px) 100vw, 50vw"
/>
// Next.jsは自動でWebPに変換
<Image src="/image.jpg" alt="Image" width={800} height={600} />
// → 自動的にWebPで配信(ブラウザサポート時)
// デフォルトで遅延ローディング
<Image src="/image.jpg" alt="Image" width={800} height={600} />
// priorityで無効化(Above the fold画像)
<Image src="/hero.jpg" alt="Hero" width={1200} height={600} priority />
// app/layout.tsx
import { SpeedInsights } from '@vercel/speed-insights/next'
import { Analytics } from '@vercel/analytics/react'
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<SpeedInsights />
<Analytics />
</body>
</html>
)
}
import Image from 'next/image'
export default function Gallery({ images }) {
return (
<div className="grid grid-cols-3 gap-4">
{images.map((image, index) => (
<Image
key={image.id}
src={image.url}
alt={image.alt}
width={400}
height={300}
loading={index < 6 ? 'eager' : 'lazy'} // 最初の6枚は即座に読み込み
quality={75}
/>
))}
</div>
)
}
import dynamic from 'next/dynamic'
const Chart = dynamic(() => import('@/components/Chart'), {
loading: () => <div>Loading chart...</div>,
ssr: false, // クライアントサイドのみ
})
export default function Dashboard() {
return (
<div>
<h1>Dashboard</h1>
<Chart data={data} />
</div>
)
}
# Chrome DevTools → Lighthouse
# または
pnpm add -D lighthouse
npx lighthouse https://example.com --view
pnpm add web-vitals
// app/layout.tsx
'use client'
import { useEffect } from 'react'
import { onCLS, onFID, onLCP } from 'web-vitals'
export function WebVitals() {
useEffect(() => {
onCLS(console.log)
onFID(console.log)
onLCP(console.log)
}, [])
return null
}
ANALYZE=true pnpm build
パフォーマンス分析
Lighthouse スコアを実行して、改善点を提案してください。
バンドルサイズ削減
バンドルサイズを分析して、大きな依存関係を特定してください。
軽量な代替ライブラリを提案してください。
画像最適化
/public/images 内の画像をNext.js Imageコンポーネントに置き換えてください。
Last updated: 2025-12-26
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience