f8b21af4be
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>
161 lines
5.1 KiB
Markdown
161 lines
5.1 KiB
Markdown
---
|
|
id: wiki-2026-0508-google-lighthouse
|
|
title: Google Lighthouse
|
|
category: 10_Wiki/Topics
|
|
status: verified
|
|
canonical_id: self
|
|
aliases: [Lighthouse, Web Vitals Audit]
|
|
duplicate_of: none
|
|
source_trust_level: A
|
|
confidence_score: 0.9
|
|
verification_status: applied
|
|
tags: [performance, web-vitals, audit, ci]
|
|
raw_sources: []
|
|
last_reinforced: 2026-05-10
|
|
github_commit: pending
|
|
tech_stack:
|
|
language: JavaScript
|
|
framework: Lighthouse 12+ / lighthouse-ci
|
|
---
|
|
|
|
# Google Lighthouse
|
|
|
|
## 매 한 줄
|
|
> **"매 web page 의 performance, accessibility, best-practices, SEO, PWA 를 자동 audit"**. Chrome DevTools 내장, CLI, Node API, lighthouse-ci 의 form. 2026 현재 v12+ 가 INP (Interaction to Next Paint) 의 primary metric, LCP/CLS/INP 의 Core Web Vitals 와 align. 매 PR 마다 budget 검증 의 standard practice.
|
|
|
|
## 매 핵심
|
|
|
|
### 매 5 categories
|
|
- **Performance**: LCP, INP, CLS, TBT, FCP, Speed Index → 0-100 score.
|
|
- **Accessibility**: axe-core 기반 a11y 검사.
|
|
- **Best Practices**: HTTPS, secure headers, deprecated API.
|
|
- **SEO**: meta tags, mobile viewport, structured data.
|
|
- **PWA** (deprecated 2024 후 separate plugin).
|
|
|
|
### 매 Performance 의 weight (v12)
|
|
- LCP 25%, TBT 30%, CLS 25%, FCP 10%, SI 10%.
|
|
- INP 의 field metric 만 — lab 에서 measure X (Total Blocking Time 으로 proxy).
|
|
|
|
### 매 응용
|
|
1. Local audit (DevTools).
|
|
2. CI gate (lighthouse-ci, budgets.json).
|
|
3. Field monitoring 보조 (CrUX + RUM 와 결합).
|
|
4. PageSpeed Insights backend.
|
|
|
|
## 💻 패턴
|
|
|
|
### CLI run
|
|
```bash
|
|
npm i -g lighthouse
|
|
lighthouse https://example.com --output=html --output=json \
|
|
--output-path=./report --chrome-flags="--headless"
|
|
```
|
|
|
|
### Node programmatic
|
|
```javascript
|
|
import lighthouse from 'lighthouse'
|
|
import * as chromeLauncher from 'chrome-launcher'
|
|
|
|
const chrome = await chromeLauncher.launch({ chromeFlags: ['--headless'] })
|
|
const result = await lighthouse('https://example.com', {
|
|
port: chrome.port,
|
|
output: 'json',
|
|
onlyCategories: ['performance'],
|
|
})
|
|
console.log(result.lhr.categories.performance.score)
|
|
await chrome.kill()
|
|
```
|
|
|
|
### Lighthouse CI in GitHub Actions
|
|
```yaml
|
|
# .github/workflows/lhci.yml
|
|
name: lhci
|
|
on: [pull_request]
|
|
jobs:
|
|
lhci:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with: { node-version: 20 }
|
|
- run: npm ci && npm run build
|
|
- run: npm i -g @lhci/cli@0.14.x
|
|
- run: lhci autorun
|
|
env:
|
|
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
|
|
```
|
|
|
|
### lighthouserc.js with budgets
|
|
```javascript
|
|
module.exports = {
|
|
ci: {
|
|
collect: {
|
|
url: ['http://localhost:3000/', 'http://localhost:3000/about'],
|
|
numberOfRuns: 3,
|
|
startServerCommand: 'npm start',
|
|
},
|
|
assert: {
|
|
assertions: {
|
|
'categories:performance': ['error', { minScore: 0.9 }],
|
|
'largest-contentful-paint': ['error', { maxNumericValue: 2500 }],
|
|
'cumulative-layout-shift': ['error', { maxNumericValue: 0.1 }],
|
|
'total-blocking-time': ['warn', { maxNumericValue: 200 }],
|
|
},
|
|
},
|
|
upload: { target: 'temporary-public-storage' },
|
|
},
|
|
}
|
|
```
|
|
|
|
### User flow (multi-step)
|
|
```javascript
|
|
import { startFlow } from 'lighthouse'
|
|
import puppeteer from 'puppeteer'
|
|
|
|
const browser = await puppeteer.launch()
|
|
const page = await browser.newPage()
|
|
const flow = await startFlow(page, { name: 'Checkout flow' })
|
|
await flow.navigate('https://shop.example.com')
|
|
await flow.startTimespan({ name: 'Add to cart' })
|
|
await page.click('#add')
|
|
await flow.endTimespan()
|
|
await flow.snapshot({ name: 'Cart loaded' })
|
|
const report = await flow.generateReport()
|
|
```
|
|
|
|
## 매 결정 기준
|
|
| 상황 | Approach |
|
|
|---|---|
|
|
| Local optimization | DevTools Lighthouse panel |
|
|
| PR budget gate | lighthouse-ci + assertions |
|
|
| Multi-page audit | lhci with multiple URLs |
|
|
| SPA route transitions | User flows API |
|
|
| Real-user metrics | CrUX / web-vitals JS (Lighthouse 의 X) |
|
|
|
|
**기본값**: 매 lhci + budgets.json + GitHub Action + 3 runs median.
|
|
|
|
## 🔗 Graph
|
|
- 부모: [[Performance_Profiling_and_Memory|Performance Profiling]]
|
|
- 응용: [[CI_CD_Pipeline|CI_CD Pipeline]] · [[Continuous Integration (CI)]]
|
|
- Adjacent: [[Core Web Vitals Optimization (INP, LCP 개선)|Cumulative Layout Shift (CLS)]] · [[SPA 라우트 전환 성능 최적화]]
|
|
|
|
## 🤖 LLM 활용
|
|
**언제**: pre-deploy quality gate, regression catch, web vitals tracking.
|
|
**언제 X**: 매 real-user perf 측정 (lab condition 일 뿐 — RUM 사용). Native app, server-only API.
|
|
|
|
## ❌ 안티패턴
|
|
- **단일 run score 의 의존**: variance 가 큼 — 매 median of 3-5 runs.
|
|
- **Lab score = field score 의 가정**: throttling profile 이 user 와 다름. 매 CrUX 와 cross-check.
|
|
- **High score 만 의 chase**: 100 score ≠ good UX. 매 INP/LCP 의 actual budget 의 focus.
|
|
- **CI 에 emulated mobile 만 의 test**: desktop user 도 audit.
|
|
|
|
## 🧪 검증 / 중복
|
|
- Verified (web.dev/lighthouse, lighthouse-ci docs, Lighthouse 12 release notes 2025).
|
|
- 신뢰도 A.
|
|
|
|
## 🕓 Changelog
|
|
| 날짜 | 변경 |
|
|
|---|---|
|
|
| 2026-05-08 | Phase 1 |
|
|
| 2026-05-10 | Manual cleanup — Lighthouse 12 + CI integration patterns |
|