Skip to content

Lighthouse Integration

FAT Agent wraps Google Lighthouse CLI for accurate Core Web Vitals measurement including LCP, FID, CLS, and overall performance scores.


Usage

python scripts/lighthouse.py --url https://example.com --output /tmp/lighthouse.json

Options

Flag Default Description
--url Required URL to audit
--output stdout Path for JSON results
--preset desktop Device preset: desktop or mobile
--categories performance Lighthouse categories to run

Prerequisites

Lighthouse requires Node.js and Chrome/Chromium:

npm install -g lighthouse

How It Works

  1. Check -- verifies Lighthouse CLI is installed
  2. Run -- executes lighthouse with JSON output format
  3. Parse -- extracts Core Web Vitals and category scores
  4. Merge -- results are available for integration with the main audit

Fallback Behaviour

When Lighthouse is not installed, the script:

  • Logs a warning that Lighthouse is unavailable
  • Returns an empty result set with a lighthouse_available: false flag
  • The main audit continues without Lighthouse data
  • Performance scores use HTML-based heuristics instead

Output Format

{
  "lighthouse_available": true,
  "performance_score": 87,
  "metrics": {
    "first_contentful_paint": 1.2,
    "largest_contentful_paint": 2.1,
    "total_blocking_time": 150,
    "cumulative_layout_shift": 0.05,
    "speed_index": 2.8
  },
  "opportunities": [
    {
      "id": "render-blocking-resources",
      "title": "Eliminate render-blocking resources",
      "savings_ms": 450
    }
  ]
}