Lighthouse is an open-source, automated tool designed to elevate the quality of web pages. Whether the page is public or requires authentication, Lighthouse can audit it. This powerful tool conducts comprehensive checks across various aspects of web development, including performance, accessibility, progressive web apps, and SEO.
Think of Lighthouse as a meticulous inspector for your website. You provide it with a URL, and it rigorously scans the page, performing a series of audits. After its scan, Lighthouse delivers a detailed report outlining the page’s performance. The audits that didn’t pass serve as clear indicators of areas needing improvement. Crucially, each audit comes with a reference explaining its importance and providing guidance on how to rectify any issues. This makes Lighthouse not just a scanning tool, but also an educational resource for web developers.
To ensure your websites remain consistently high-performing, consider leveraging Lighthouse CI. This continuous integration tool helps prevent regressions, keeping your site’s quality in check over time.
Getting Started with Lighthouse
Lighthouse offers several workflows to suit different user preferences and technical environments.
Running Lighthouse Directly in Chrome DevTools
For a user-friendly approach, Chrome DevTools integrates Lighthouse directly into the browser. Here’s how to use it:
-
Ensure you have Google Chrome: Download Google Chrome for Desktop if you haven’t already.
-
Navigate to Your Target URL: Open Chrome and go to the specific web page you intend to audit. Lighthouse can analyze any URL accessible on the web.
-
Access Chrome DevTools: Open Chrome DevTools.
-
Select the Lighthouse Tab: Within DevTools, locate and click on the Lighthouse tab.
-
Initiate Audit: Click Analyze page load. You’ll see a list of audit categories; keep them all enabled for a comprehensive scan.
-
Run Audit: Click Run audit. Lighthouse will take between 30 to 60 seconds to scan the page and compile a report.
Using the Node Command Line Tool
For developers who prefer command-line interfaces, Lighthouse is also available as a Node module.
- Install Google Chrome: Download Google Chrome for Desktop.
- Install Node.js: Ensure you have the current Long-Term Support version of Node installed.
- Install Lighthouse: Use npm to install Lighthouse globally:
npm install -g lighthouse
To perform an audit, simply run:
lighthouse <URL>
For a list of all available options, use the help command:
lighthouse --help
Programmatic Use of the Node Module
For more advanced integrations, Lighthouse can be run programmatically as a Node module. Refer to Using programmatically for detailed examples and instructions.
Auditing via PageSpeed Insights
PageSpeed Insights, a popular website performance analysis tool, also incorporates Lighthouse.
- Go to PageSpeed Insights: Navigate to PageSpeed Insights.
- Enter URL: Input the web page URL you want to analyze.
- Analyze: Click Analyze.
Running Lighthouse as a Chrome Extension
For quick, in-browser audits, the Lighthouse Chrome Extension is a convenient option.
-
Install the Extension: Find and install the Lighthouse extension from the Chrome Web Store.
-
Navigate to the Page: In Chrome, go to the page you wish to audit.
-
Open Lighthouse Extension: Click the Lighthouse icon, typically located next to the Chrome address bar or within Chrome’s extension menu.
-
Generate Report: Click Generate report. Lighthouse will scan the current page and open a new tab displaying the audit results.
Sharing and Reviewing Lighthouse Reports Online
The Lighthouse Viewer provides a platform to view and share reports conveniently online.
Sharing Reports as JSON
The Lighthouse Viewer utilizes the JSON output of Lighthouse reports. To generate this output:
- From a Lighthouse report: In the report interface, click more_vert (the vertical three-dots menu) and select Save as JSON.
- Command line: Use the command
lighthouse --output json --output-path <report-path>.json <URL>
.
To view a JSON report:
- Open the Lighthouse Viewer.
- Drag and drop the JSON file onto the Viewer, or click anywhere within the Viewer to use your file navigator to select the file.
Sharing Reports via GitHub Gists
For version-controlled sharing, GitHub gists are an excellent option.
To export a report as a gist directly from the report interface:
- Click more_vert menu, then select Open In Viewer.
- In the Viewer, click more_vert menu, and then Save as Gist. You may be prompted to grant Lighthouse permission to access your GitHub data for gist creation.
To export from the CLI: Manually create a gist on GitHub and paste the JSON report content into it. Ensure the gist filename ends with .lighthouse.report.json
.
To view a report from a gist:
- Append
?gist=<gist_id>
to the Viewer URL:https://googlechrome.github.io/lighthouse/viewer/?gist=<gist_id>
. - Alternatively, open the Viewer and paste the gist URL into it.
Extending Lighthouse Capabilities
Lighthouse is designed to be adaptable and relevant for a broad spectrum of web developers. Two key features enhance its flexibility:
Stack Packs
Websites are built using diverse technologies. Stack packs enable Lighthouse to detect the platform your site uses (e.g., CMS, JavaScript frameworks) and provide tailored, stack-specific recommendations. These are curated by community experts, ensuring relevant and actionable advice.
Contribute to stack packs by reviewing the Contributing Guidelines.
Lighthouse Plugins
For specialized needs, Lighthouse plugins allow domain experts to extend its functionality. Plugins enable the creation of new audits using the data Lighthouse collects. A plugin is essentially a Node module that implements custom checks, adding them as a new category in Lighthouse reports.
Learn more about plugin development in the Plugin Handbook within the Lighthouse GitHub repository.
Integrating Lighthouse into Your Products
If you are integrating Lighthouse into your products or services, we encourage it! We aim for widespread adoption of Lighthouse to improve web quality.
Please review the Guidelines and Brand Assets for Integrating Lighthouse to ensure proper brand representation.
Contributing to the Lighthouse Project
Lighthouse is an open-source project, and contributions are highly encouraged! Explore the Issue tracker to find opportunities to contribute, such as fixing bugs or enhancing audits. The Issues section is also a valuable space for discussions about performance metrics and new audit ideas.