웹 성능 최적화는 페이지 로딩 속도와 사용자 경험을 향상시키는 기술의 총체다. Google의 Core Web Vitals(LCP, FID/INP, CLS)가 SEO와 직결되어 성능 최적화는 비즈니스 지표에 직접 영향을 미친다.
Core Web Vitals
| 지표 | 의미 | 좋음 |
|---|
| LCP (Largest Contentful Paint) | 주요 콘텐츠 로딩 완료 | < 2.5s |
| INP (Interaction to Next Paint) | 상호작용 응답성 | < 200ms |
| CLS (Cumulative Layout Shift) | 레이아웃 안정성 | < 0.1 |
이미지 최적화
html
<!-- 현대적 이미지 최적화 -->
<picture>
<source srcset="hero.avif" type="image/avif">
<source srcset="hero.webp" type="image/webp">
<img src="hero.jpg" alt="Hero" width="800" height="400"
loading="lazy" decoding="async">
</picture>
<!-- Next.js Image 컴포넌트 (자동 최적화) -->
<Image src="/hero.jpg" width={800} height={400}
alt="Hero" priority />
tsx
// React lazy loading
import { lazy, Suspense } from 'react';
const HeavyChart = lazy(() => import('./HeavyChart'));
function Dashboard() {
return (
<Suspense fallback={<div>Loading...</div>}>
<HeavyChart />
</Suspense>
);
}
성능 측정
javascript
// Web Performance API
const observer = new PerformanceObserver(list => {
for (const entry of list.getEntries()) {
console.log(entry.name, entry.startTime);
}
});
observer.observe({ entryTypes: ['largest-contentful-paint', 'layout-shift'] });
// Lighthouse CI
// lighthouse https://example.com --output json
주요 최적화 기법
- •번들 크기 최소화: 트리 쉐이킹, 코드 분할
- •캐싱: CDN, HTTP 캐시 헤더, Service Worker
- •렌더링 최적화: CSS in critical path, preload/prefetch
- •폰트 최적화: font-display: swap, subset
관련 개념