[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
+159 -76
View File
@@ -2,99 +2,182 @@
id: wiki-2026-0508-lighthouse
title: Lighthouse
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: []
aliases: [Google Lighthouse, Lighthouse CI, LHCI]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
tags: [uncategorized]
confidence_score: 0.9
verification_status: applied
tags: [web-performance, lighthouse, lhci, audit, cwv, treosh]
raw_sources: []
last_reinforced: 2026-05-08
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: unspecified
framework: unspecified
tech_stack: { language: js, framework: lighthouse/lhci }
---
# [[Lighthouse|Lighthouse]]
# Lighthouse
## 📌 한 줄 통찰 (The Karpathy Summary)
Lighthouse는 [[Chrome DevTools|Chrome DevTools]]에 내장되어 웹 애플리케이션의 성능을 측정하고 종합적인 감사를 제공하는 도구입니다 [1, 2]. 주로 [[Core Web Vitals|Core Web Vitals]] 지표를 기반으로 구체적이고 실행 가능한 성능 최적화 권장 사항을 제시하며, CI(지속적 통합) 파이프라인에서 실행하여 프로덕션 환경으로 성능 회귀(Performance regression)가 유입되는 것을 방지할 수 있습니다 [2].
## 한 줄
> **"매 lab metric 의 표준"**. Performance/A11y/SEO/Best Practices/PWA 5 카테고리 lab 감사, CI 게이트로 회귀 차단.
## 📖 Core 대Content
* **성능 감사 및 문제 진단 워크플로우:** 성능 최적화의 첫 단계로 Lighthouse를 실행하여 어떤 Core Web Vital 지표가 개선이 필요한지 식별하는 것이 권장됩니다 [1]. 이후 React DevTools Profiler와 같은 도구를 사용해 가장 느린 컴포넌트를 격리하고 개선 사항을 적용한 뒤, 다시 측정하여 결과를 확인하는 방식으로 사용됩니다 [1].
* **렌더링 차단 리소스(Render-[[Blocking|Blocking]] resources) 분석:** Lighthouse는 페이지 렌더링을 방해하는 리소스를 분석하고 식별합니다. 특히 실제로 페이지 렌더링을 지연시키는 리소스만을 선별하여 보여주기 때문에 불필요한 오탐(false positives)을 피하는 데 유용합니다 [3, 4].
* **LCP 및 주요 요청 체인(Critical Request Chains) 시각화:** 사이트의 LCP(Largest Contentful Paint) 요소 및 렌더링 시점을 식별해 줍니다 [5]. 또한 각 LCP 단계와 거기에 소요된 시간을 분석하여 최적화 노력을 어디에 집중해야 할지 돕고, 복잡한 사이트에서는 별도의 감사를 통해 렌더링 차단 여부와 무관하게 중요도가 높은 리소스들의 요청 체인을 시각적으로 강조해 줍니다 [5].
* **실제 사용자 데이터(RUM)와의 병행 사용:** Lighthouse는 실험실 도구(Lab tool)이므로 실제 사용자의 기기, 네트워크 상태 및 사용 패턴을 완벽히 반영하지 못할 수 있습니다 [1]. 따라서 프로덕션 환경에서는 `web-vitals` 자바스크립트 라이브러리를 활용해 실제 사용자 데이터(Field data)를 수집하여 함께 모니터링하는 것이 필수적입니다 [1, 2].
## 매 핵심
### 매 lab vs field
- **Lighthouse = lab**: 통제된 환경, 한 번 실행, deterministic-ish
- **CrUX/RUM = field**: 실 사용자, 분포, p75
- 둘 다 필요. Lab 은 회귀 catch, field 는 진실
## 🔗 지식 연결 (Graph)
- **Related Topics:** [[Core Web Vitals|Core Web Vitals]], LCP, Render-blocking resources, [[Chrome DevTools|Chrome DevTools]]
- **Projects/Contexts:** [[React Performance Optimization|React Performance Optimization]], [[Critical Rendering Path|Critical Rendering Path]]
- **Contradictions/Notes:** 다른 성능 측정 도구인 WebPageTest가 모든 렌더링 차단 리소스를 명확하게 표시하는 반면, Lighthouse는 페이지 렌더링을 실제로 지연시키는 요소만 미묘하게 강조한다는 접근 방식의 차이가 있습니다 [3].
### 매 카테고리
- Performance (LCP/CLS/TBT/SI/FCP) — TBT 가 lab proxy for INP
- Accessibility (axe-core 기반)
- Best Practices (HTTPS, console error, ...)
- SEO
- PWA (deprecated 진행 중)
---
*Last updated: 2026-04-25*
### 매 응용
1. PR 마다 LHCI 게이트
2. Custom audit (회사 정책)
3. Multi-page coverage (여러 URL)
4. Budgets (size, count)
5. Treosh GitHub Action 으로 PR 코멘트
## 📖 구조화된 지식 (Synthesized Content)
## 💻 패턴
**추출된 패턴:**
> *(TODO)*
**세부 내용:**
- *(TODO)*
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
**언제 이 지식을 쓰는가:**
- *(TODO)*
**언제 쓰면 안 되는가:**
- *(TODO)*
## 🧪 검증 상태 (Validation)
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 없음
- **정책 변화:** 없음
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
### Pattern 1: CLI 기본
```bash
npm i -g lighthouse
lighthouse https://example.com \
--output=json --output=html \
--output-path=./report \
--chrome-flags="--headless"
```
## 🤔 의사결정 기준 (Decision Criteria)
### Pattern 2: LHCI 설정
```js
// lighthouserc.cjs
module.exports = {
ci: {
collect: {
url: ["http://localhost:3000/", "http://localhost:3000/about"],
numberOfRuns: 3,
startServerCommand: "npm run start",
},
assert: {
assertions: {
"categories:performance": ["error", { minScore: 0.9 }],
"categories:accessibility": ["error", { minScore: 0.95 }],
"largest-contentful-paint": ["error", { maxNumericValue: 2500 }],
"cumulative-layout-shift": ["error", { maxNumericValue: 0.1 }],
},
},
upload: { target: "temporary-public-storage" },
},
};
```
```bash
npx lhci autorun
```
**선택 A를 써야 할 때:**
- *(TODO)*
### Pattern 3: Treosh GitHub Action
```yaml
# .github/workflows/lhci.yml
- uses: treosh/lighthouse-ci-action@v12
with:
urls: |
https://staging.example.com
https://staging.example.com/products
configPath: ./lighthouserc.cjs
uploadArtifacts: true
temporaryPublicStorage: true
```
**선택 B를 써야 할 때:**
- *(TODO)*
### Pattern 4: Performance budget
```json
// budgets.json
[{
"path": "/*",
"resourceSizes": [
{ "resourceType": "script", "budget": 200 },
{ "resourceType": "image", "budget": 300 },
{ "resourceType": "total", "budget": 800 }
],
"resourceCounts": [
{ "resourceType": "third-party", "budget": 10 }
]
}]
```
**기본값:**
> *(TODO)*
### Pattern 5: Custom audit
```js
// custom-audit.js
const { Audit } = require("lighthouse");
class NoConsoleErrorAudit extends Audit {
static get meta() {
return { id: "no-console-error", title: "No console errors", scoreDisplayMode: "binary",
requiredArtifacts: ["ConsoleMessages"] };
}
static audit(artifacts) {
const errors = artifacts.ConsoleMessages.filter(m => m.level === "error");
return { score: errors.length === 0 ? 1 : 0,
details: { type: "table", items: errors } };
}
}
module.exports = NoConsoleErrorAudit;
```
## ❌ 안티패턴 (Anti-Patterns)
### Pattern 6: Programmatic API
```js
import lighthouse from "lighthouse";
import * as chromeLauncher from "chrome-launcher";
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
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();
```
### Pattern 7: Multi-config (mobile + desktop)
```bash
lhci autorun --collect.settings.preset=desktop # desktop
lhci autorun # default mobile
```
## 매 결정 기준
| 상황 | Tool |
|---|---|
| Lab CI 게이트 | Lighthouse CI |
| 실제 사용자 측정 | RUM (web-vitals.js) |
| INP 진짜 디버깅 | LoAF (lab Lighthouse 만으론 부족) |
| Multi-page audit | LHCI urls[] |
| 빠른 1회 audit | Chrome DevTools Lighthouse panel |
**기본값**: LHCI + treosh action + budgets, 회귀시 PR block, RUM 으로 field 보완.
## 🔗 Graph
- 부모: [[Web_Performance]]
- 변형: [[PageSpeed_Insights]], [[WebPageTest]]
- 응용: [[Core_Web_Vitals]], [[Performance_Budget]]
- Adjacent: [[Long_Animation_Frames_API]], [[RUM]]
## 🤖 LLM 활용
**언제**: Lighthouse JSON 결과 → 우선순위 issue 정리, 해결 PR 초안.
**언제 X**: deterministic threshold (assertion config 직접 작성이 명확), 회귀 진단 (LoAF/profiler 가 정확).
## ❌ 안티패턴
- Lab 점수만 보고 production 판단 → field (CrUX) 다름
- 1회 실행으로 결정 → variance 큼, numberOfRuns >= 3
- Localhost CPU/network throttle 무시 → 실 환경 다른 결과
- Score 90 = "끝" → metric 자체 (LCP/CLS) 가 진짜 목표
- Custom audit 없이 회사 정책 강제 안 함 → 일관성 부재
## 🧪 검증 / 중복
- Verified (Lighthouse docs, LHCI docs, treosh/lighthouse-ci-action). 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — LHCI + budgets + custom audit + treosh patterns |