Files
2nd/10_Wiki/Topics/Frontend/브라우저 렌더링 파이프라인(Critical Rendering Path).md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

154 lines
5.3 KiB
Markdown

---
id: wiki-2026-0508-브라우저-렌더링-파이프라인-critical-renderin
title: 브라우저 렌더링 파이프라인(Critical Rendering Path)
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Critical Rendering Path, CRP, 렌더링 파이프라인]
duplicate_of: none
source_trust_level: A
confidence_score: 0.95
verification_status: applied
tags: [frontend, browser, rendering, performance, web-vitals]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: javascript
framework: browser
---
# 브라우저 렌더링 파이프라인(Critical Rendering Path)
## 매 한 줄
> **"매 HTML/CSS/JS 의 화면 픽셀로 도달하는 순차적 stage chain"**. 매 Parse → Style → Layout → Paint → Composite 의 5단계 — 매 stage 의 cost 의 understand 의 LCP/INP/CLS 의 optimize 의 critical path.
## 매 핵심
### 매 5 stages
1. **Parse**: HTML → DOM, CSS → CSSOM (parallel, but CSS blocks render).
2. **Style**: DOM + CSSOM → Render Tree (visible nodes only — `display:none` excluded).
3. **Layout (Reflow)**: geometry 계산 — x/y/width/height.
4. **Paint**: pixel 채우기 — color, image, shadow, text.
5. **Composite**: layer 합성 — GPU 의 transform/opacity 의 처리.
### 매 blocking resources
- **CSS**: render-blocking — CSSOM 의 완성 의 wait.
- **JS (sync)**: parser-blocking — DOM 의 build 의 pause.
- **JS (`async`)**: 매 download parallel, execute when ready (parser pause).
- **JS (`defer`)**: 매 download parallel, execute after DOMContentLoaded.
### 매 layer-promote triggers
- `transform: translateZ(0)` / `will-change: transform`.
- `position: fixed` (modern Chromium).
- `<video>`, `<canvas>`, animated `transform/opacity`.
## 💻 패턴
### Critical CSS inlining
```html
<head>
<style>
/* above-the-fold CSS only — 14KB 이내 */
body { margin: 0; font-family: system-ui; }
.hero { height: 100vh; background: #000; }
</style>
<link rel="preload" href="/main.css" as="style"
onload="this.onload=null;this.rel='stylesheet'">
</head>
```
### Composite-only animation (cheap)
```css
/* O — composite layer 만 — 60fps 안정 */
.card { transition: transform 200ms, opacity 200ms; }
.card:hover { transform: translateY(-4px); opacity: 0.9; }
/* X — layout + paint trigger — jank */
.bad { transition: top 200ms, height 200ms; }
```
### Reflow 의 batch (read-then-write)
```js
// X — interleave read/write — forced reflow per write
elements.forEach(el => {
const w = el.offsetWidth; // read (force layout)
el.style.width = (w * 2) + 'px'; // write (invalidate)
});
// O — batch read, then batch write
const widths = elements.map(el => el.offsetWidth);
elements.forEach((el, i) => el.style.width = (widths[i] * 2) + 'px');
```
### Resource priority hint
```html
<link rel="preload" href="/font.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preconnect" href="https://api.example.com">
<img src="/hero.jpg" fetchpriority="high">
<img src="/below-fold.jpg" loading="lazy" fetchpriority="low">
```
### Web Vitals 의 측정 (PerformanceObserver)
```js
new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (entry.name === 'first-contentful-paint') console.log('FCP', entry.startTime);
}
}).observe({ type: 'paint', buffered: true });
new PerformanceObserver((list) => {
const lcp = list.getEntries().at(-1);
console.log('LCP', lcp.renderTime || lcp.loadTime);
}).observe({ type: 'largest-contentful-paint', buffered: true });
```
### `content-visibility` (off-screen skip)
```css
/* 매 viewport 밖 section 의 layout/paint 의 skip */
.section { content-visibility: auto; contain-intrinsic-size: 800px; }
```
### `requestIdleCallback` 의 non-critical work
```js
requestIdleCallback(() => {
prefetchRoutes();
reportAnalytics();
}, { timeout: 2000 });
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| LCP 느림 | Critical CSS inline + preload hero image + `fetchpriority="high"` |
| INP 느림 | long task 의 break (`scheduler.yield()`), event handler 의 simplify |
| CLS 발생 | image/iframe 의 width/height 의 명시, `font-display: optional` |
| Animation jank | `transform/opacity` 만 의 사용, `will-change` 의 sparingly |
| Long list | `content-visibility: auto` + `contain-intrinsic-size` |
**기본값**: 매 Critical CSS inline (14KB), JS `defer`, image lazy + dimensions, transform-only animation.
## 🔗 Graph
- 부모: [[Web Vitals]]
- 응용: [[성능 최적화(Reflow & Repaint)]]
## 🤖 LLM 활용
**언제**: Web Vitals regression 의 분석, layout thrash 의 detect, optimization 의 prioritize.
**언제 X**: Real User Monitoring (RUM) 의 raw data 의 aggregate (specialized tooling 의 use).
## ❌ 안티패턴
- **모든 element 에 `will-change`**: 매 GPU memory 의 explosion — 매 sparingly.
- **Sync JS 의 `<head>`**: 매 parser block — 매 `defer` 의 사용.
- **`@import` chain**: 매 sequential CSS load — 매 `<link>` 의 use.
- **Layout-trigger animation**: 매 `top/left/width` 의 transition — 매 `transform` 의 substitute.
## 🧪 검증 / 중복
- Verified (web.dev/learn/performance, Chrome DevTools docs, Ilya Grigorik CRP).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — CRP 5 stages + composite animation + Web Vitals 의 정리 |