LightHouse 5.6.0 is an open-source project written in Javascript and began in January 2016 under Apache 2,0 License. On GitHub, it is a project of the Organisation Google Chrome knows a huge success and counts roughly 10,000 stars and 100 contributors. It is already stable, see latest release. It is an automated tool for improving the quality of web pages. You can run it against any web page, public or requiring authentication. It has audits for performance, accessibility, progressive web apps, and more.

Logo of Lighthouse
Logo of Lighthouse

You can run Lighthouse as a Chrome Extension, from the command line, or as a Node module. You give Lighthouse a URL to audit, it runs a series of audits against the page, and then it generates a report on how well the page did. From there, use the failing audits as indicators on how to improve the page. Each audit has a reference doc explaining why the audit is important, as well as how to fix it.

The rapport is divided into 4 categories:

  1. Progressive Web App: tests if your app is corect progressive web app.
  2. Performance: measures if the page is loaded quickly.
  3. Accessibility: checks if the content of your page is accessible.
  4. Best Practices: checks if good practices are applied.

The goal is to have a score of 100 for each category and for each web page of your website:

Lighthouse scores by report category
Lighthouse scores by report category

You can export report under HTML or JSON format, then import these format or see directly report due to LightHouse Viewer (online version). You can install on-premises version directly from the Git repository if LightHouse Viewer .

Export, import and view LightHouse report
Export, import and view LightHouse report

The work flow of LightHouse core is described by the following chart:

Architecture of Lighthouse Core
Architecture of Lighthouse Core

See details of the architecture.

The project Lighthouse has 5 main components:

  1. lighthouse-cli: allows to call lighthouse services from command line.
  2. lighthouse-core: allows to generate report to measure the quality of your app at some urls.
  3. lighthouse-extension: allows to call lighthouse services from an Google Chrome extension.
  4. lighthouse-logger: allows common logs.
  5. lighthouse-viewer: allows to see report in your web browser or to import reports under JSON or HTML format.

Before installing LightHouse 2.4.0, we must have:

As lighthouse is a very recent project, you can use Canary version for Google Chrome.

Google Chrome, Chromium and Canary version
Google Chrome, Chromium and Canary version

Reminder you in a nutshell that Google Chrome is the Chromium open source project built, packaged, and distributed by Google. You can see a few differences . It has 4 versions Stable, Beta, Dev, Canary for MAC, Windows and Linux for desktops and Android, iOS for smart phones and tablets.

For example, test LightHouse on this blog. Suppose that you have this file urls.txt containing one URL per line:

Run this bash script to get one report by url:

for url in $(cat urls.txt); do
  echo -n "--"
  echo "$i ${url}" | tee -a matching_url_report.txt
  echo -n "--"
  lighthouse "${url}" --output=json --output-path="report-$i.json"

Then run this python script

python3 urls.txt reports.csv

See code.

You get this csv file reports.csv. Visualize with matplotlib library:

 Charts of scores for a set of URLs
Charts of scores for a set of URLs
url date pwa performance accessibility best-practices 2017-08-17 45.45 46.12 91.43 69.23 2017-08-17 45.45 48.71 91.43 69.23 2017-08-17 36.36 36.53 88.57 69.23 2017-08-17 45.45 40.88 91.43 61.54 2017-08-17 45.45 46.12 88.57 69.23 2017-08-17 36.36 40.18 88.57 69.23


Creative Commons Attribution 4.0 International License:
Also read