Skip to content

🚦Generate badges based on Lighthouse performance.

License

Notifications You must be signed in to change notification settings

MyActionWay/lighthouse-badges

 
 

Repository files navigation

Build Status Code Coverage  vulnerabilities pending...  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 sites's awesome Lighthouse performance? Then this is the package for you!

Examples

Plastic Badges

Lighthouse Performance Badge Lighthouse Accessibility Badge Lighthouse Best Practices Badge Lighthouse SEO Badge Lighthouse PWA Badge

Single Plastic Badge

Lighthouse

Pagespeed Badge | New

PageSpeed

In this forked version, I, Sitdisch, added this pagespeed badge. The inserted code is based on the magnificent work of Ankur Parihar [License: Apache-2.0; Copyright (c) 2021 Ankur Parihar].

Usage

Help

usage: lighthouse-badges [-h] [-v] [-s] [-r]
                         [-b {flat,flat-square,plastic,for-the-badge,pagespeed,social}]
                         [-l "PRECEDING_LABEL "]
                         [-o OUTPUT_PATH]
                         [-u URLS ...]


Generate badges based on lighthouse performance.

Optional arguments:
 -h, --help             Show this help message and exit.
 -v, --version          Show program's version number and exit.
 -s, --single-badge     Output only one single badge averaging all lighthouse
                        categories' scores; not possible for the pagespeed badge
 -b, --badge-style      Define look and feel for the badge.
                        Options: flat, flat-square, plastic, for-the-badge,
                        pagespeed, social [default: flat]
 -l, --preceding-label  Define which label should precede category labels
                        e.g. "" for nothing [default: "Lighthouse "]
 -o, --output-path      Define output path for artifacts
 -r, --save-report      Save lighthouse report as html for every supplied url

Required arguments:
  -u, --urls            The lighthouse badge(s) will contain the respective
                        average score(s) of all the urls supplied, combined

Additionally you can pass parameters to the lighthouse process directly via environment variable:

# This will pass '--preset=desktop' to the lighthouse process
export LIGHTHOUSE_BADGES_PARAMS="--preset=desktop"
lighthouse-badges --urls https://www.youtube.com/

Run

Hint: Only node >= 12 is supported.

Option 1: npm

npm i -g lighthouse-badges
lighthouse-badges --urls https://www.youtube.com/ https://www.youtube.com/feed/trending -o test_results

Option 2: npx

npx lighthouse-badges --urls https://www.youtube.com/ https://www.youtube.com/feed/trending -o test_results

Option 3: Docker

# Warning, the docker version may alter the lighthouse results
docker run --rm \
    -v $PWD/test_results:/home/chrome/reports \
    emazzotta/lighthouse-badges \
    /bin/sh -c "lighthouse-badges --urls https://www.youtube.com/ https://www.youtube.com/feed/trending"

Contributing

See contribution guideline

Sponsors

Sponsored by JetBrains

Jetbrains Logo

Author

Emanuele Mazzotta

About

🚦Generate badges based on Lighthouse performance.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%