Files
2nd/10_Wiki/Topics/Programming & Language/Google Lighthouse.md
T
koriweb d8a80f6272 chore(wiki): dangling 링크 canonical 정규화 (768파일/1200건)
이름만 다른(표기 변형) [[위키링크]]를 대상 문서의 canonical 제목으로 치환해
끊겼던 1,200개 링크를 연결. 제목/파일명 정규화 일치만 적용하고 별칭 매칭은
과병합 위험으로 제외(애매성 가드). 원본은 _link_reconcile_backup/ 에 백업.
도구: Datacollect/scripts/link_reconcile_apply.mjs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 12:24:15 +09:00

5.0 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-google-lighthouse Google Lighthouse 10_Wiki/Topics verified self
Lighthouse
Web Vitals Audit
none A 0.9 applied
performance
web-vitals
audit
ci
2026-05-10 pending
language framework
JavaScript 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

npm i -g lighthouse
lighthouse https://example.com --output=html --output=json \
  --output-path=./report --chrome-flags="--headless"

Node programmatic

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

# .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

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)

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
  • 응용: CI_CD_Pipeline · Continuous Integration (CI)
  • Adjacent: Core Web Vitals Optimization (INP, LCP, 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