Skip to content
プロジェクト

emazzotta/lighthouse-badges

GitHubで見る

概要

🚦 Generate badges (shields.io) based on Lighthouse performance.

システム・インフラ

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

Build Status NPM downloads NPM version License

Lighthouse Badges

Lighthouse

This package allows you to easily create Lighthouse badges for all Lighthouse categories.
Ever wanted to brag about your site's awesome Lighthouse performance? Then this is the package for you!

https://github.com/user-attachments/assets/c94f48eb-3ac5-4013-8b4e-9327ec108a8c

Examples

All Badges

Lighthouse Accessibility Badge Lighthouse Agentic Browsing Badge Lighthouse Best Practices Badge Lighthouse Performance Badge Lighthouse SEO Badge

Single Badge

Lighthouse

Usage

Help

usage: lighthouse-badges [-h] [-v] [-s]
                         [-b {flat,flat-square,plastic,for-the-badge,social}]
                         [-o OUTPUT_PATH] [-r] -u URL

Generate gh-badges (shields.io) based on lighthouse performance.

options:
  -h, --help            show this help message and exit
  -v, --version         Show the version of the tool
  -s, --single-badge    Output only one single badge averaging all lighthouse
                        categories' scores
  -b, --badge-style {flat,flat-square,plastic,for-the-badge,social}
                        Define look and feel for the badge
  -o, --output-path OUTPUT_PATH
                        Define output path for artifacts
  -r, --save-report     Save the lighthouse report as html next to the badges

Required arguments:
  -u, --url URL         The url whose lighthouse scores the badge(s) will show

Additionally, you can pass parameters configurations to the lighthouse process directly via environment variable path to the config file:

# The variable name matters, but the path can be anything
export LIGHTHOUSE_BADGES_CONFIGURATION_PATH="$HOME/.lhb-config.json"

# "extends": "lighthouse:default" is needed, the rest is optional
cat >| "$LIGHTHOUSE_BADGES_CONFIGURATION_PATH" << 'EOF'
{
  "extends": "lighthouse:default",
  "settings": {
    "extraHeaders": {
      "Authorization": "Bearer ..."
    },
    "onlyCategories": [
      "performance",
      "seo"
    ],
    "formFactor": "mobile"
  }
}
EOF

lighthouse-badges --url https://www.youtube.com/

See here for more configuration examples in the official lighthouse docs.

Chrome runs with its sandbox. Where the sandbox cannot start, for example as root in a container, set LIGHTHOUSE_BADGES_DISABLE_SANDBOX=true to pass --no-sandbox. The Docker image sets it.

Run

Options 1 and 2 install with Bun and run the command on Node.js >= 22.19, which Lighthouse 13 requires. The Docker image brings its own runtime.

Option 1: bun

bun install -g lighthouse-badges
lighthouse-badges --url https://www.youtube.com/ -o test_results

Option 2: bunx

bunx lighthouse-badges --url https://www.youtube.com/ -o test_results

Option 3: Docker

# May alter lighthouse results due to performance differences compared to running directly on host
docker run --rm \
    -v $PWD/test_results:/home/chrome/reports \
    emazzotta/lighthouse-badges \
    /bin/sh -c "lighthouse-badges --url https://www.youtube.com/"

Develop

The build needs jq on the PATH.

bun run start # To run the lighthouse-badges code on google.com

Contributing

See contribution guideline

Sponsors

Sponsored by JetBrains

Jetbrains Logo

Author

Emanuele Mazzotta

関連プロジェクトを探す

読み込み中…