Skip to content
Proyectos

emazzotta/lighthouse-badges

Ver en GitHub

Acerca de

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

Sistemas e infraestructura

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

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

Explorar proyectos relacionados

Cargando…