Lighthouse can be run as a Chrome Extension, from the command line, or used programmatically as a Node module. You give Lighthouse a URL that you want to audit, it runs a barrage of tests against the page, and then it generates a report on how well the page did. From here you can use the failing tests as indicators on what you can do to improve your app.
Setting up Lighthouse
There are two primary ways to run Lighthouse, as a Chrome Extension, or as a command line tool. The Chrome Extension provides a more user-friendly interface for reading reports. The command line tool enables you to integrate Lighthouse into continuous integration systems.
Install the Chrome Extension
To install the extension, do the following:
- Download Google Chrome 54 or later.
- Install the from the Chrome Webstore. Lighthouse Chrome Extension
Install the Node Command line tool
To install the Node module, do the following:
- Install Node, version 5 or greater.
Install Lighthouse as a global module:
npm install -g lighthouse
Then, run Lighthouse against a URL to audit the page:
--help flag to see available options.
Go to the page that you want to audit.
Click on the Lighthouse icon ()in the Chrome toolbar. You should see a menu.
If you want to only run a subset of the audits, click the Options button and disable the audits that you don't care about. Scroll down and press OK to confirm your changes.
Click the Generate report button to run Lighthouse's tests against the currently-open page.
When the audits are finished, Lighthouse opens up a new tab and displays a report on the page's results.
Online Report Viewer
The Lighthouse Viewer is a useful way for viewing and sharing reports, online.
There are several ways to view a report:
- When viewing the HTML version of a report, click the "Export" button in the top right corner of the report and choose "Open in Viewer".
- Drag and drop the JSON output of a Lighthouse run onto the app or click to
upload a report file. If you're a CLI user, run Lighthouse with the
--output=jsonflag to generate a json file that can be opened in the Viewer.
- Add the
?gist=GISTID"parameter to the URL of the Viewer.
- Paste the URL of a Github gist that contains a Lighthouse JSON report onto the app.
The Viewer also lets you share reports with others. Reports can be shared by clicking the share icon in the top right corner and signing in to Github. Reports are stashed as secret gists in your account so you can easily delete or update the report later on. Using Github for data storage also means free version control.
Lighthouse is open source and contributions are welcome. Check out the repository's issues tracker to find bugs that you can fix, or audits that you can create or improve upon. The issues tracker is also a good place to discuss audit metrics, ideas for new audits, or anything else related to Lighthouse.