DigitalOcean offers cloud products for every step of your journey. start with$200 in Free Credit!
Lighthouse is a free and open-source tool for measuring your website's performance, accessibility, Progressive Web App metrics, SEO, and more. The easiest way to use it is through the Chrome DevTools dashboard. After opening DevTools, you will see a "Lighthouse" tab. Clicking the "Generate Report" button will run a series of tests on the webpage and display the results right there in the Lighthouse tab. This makes it easy to test any web page, whether it's public or requires authentication.

If you don't use Chrome or Chromium-based browsers like Microsoft Edge or Brave, you can run Lighthouse through yourweb interfacebut it only works with publicly available web pages. FORnode CLI toolit is also provided for those who want to run Lighthouse audits from the command line.
All of the options listed above require some form of manual intervention. Wouldn't it be great if we could integrate Lighthouse testing into the continuous integration process so that the impact of changes to our code can be displayed inline with each pull request, and so that we can fail builds if certain performance thresholds aren't valid? Well that's exactly whyFarol CIexist!
It's a set of tools that help you identify the impact of specific code changes on your site, not just in terms of performance, but also in terms of SEO, accessibility, offline support, and other best practices. It provides a great way to enforce performance budgets, and it also helps you keep track of each reported metric so you can see how they've changed over time.
In this article, we'll look at how to set up Lighthouse CI and run it locally, making it work as part of a CI workflow using GitHub Actions. Note that Lighthouse CI also works with other CI providers such as Travis CI, GitLab CI, and Circle CI if you prefer not to use GitHub Actions.
Local configuration of Lighthouse CI
In this section, you will configure and run theFarol CIcommand line tool locally on your machine. Before proceeding, make sure you have Node.js v10 LTS or later and Google Chrome (stable) installed on your machine, then install the Lighthouse CI tool globally:
$ npm install -g @lhci/cli
Once the CLI has been successfully installed, rulhci --help
to see all available commands provided by the tool. There are eight commands available at the time of this writing.
$ lhci --helplhci <command> <options>Commands: lhci collect Run Lighthouse and save the output to a local folder lhci upload Save the output to the server lhci assert Confirm that the latest output meets expectations lhci autorun Run collect/ assert/load with sensible defaults lhci healthcheck Run diagnostics to ensure a valid configuration lhci open Open HTML reports of collected runs lhci Wizard Step by step wizard for CI tasks such as creating a project lhci server Run Lighthouse CI server Options: -- help Show help [boolean ] --version Show version number [boolean] --no-lighthouserc Disable automatic use of a .lighthouserc file. [boolean] --config Path to JSON configuration file
At this point, you're ready to configure the CLI for your project. Lighthouse CI configuration can be managed using (in ascending order of priority) a configuration file, environmental variables or CLI flags. use theAPI of Yargsto read its configuration options, which means there's a lot of flexibility in how it can be configured. the fulldocumentationcovers all In this post, we will make use of the configuration file option.
Go ahead and create onefarorc.js
file in the root of your project directory. Make sure the project is being tracked with Git because Lighthouse CI automatically infers build context settings from the Git repository. If your project doesn't use Git, you can control build context settings viaenvironmental variablesinstead of.
play lighthouserc.js
This is the simplest setup that will run and collect Lighthouse reports for a static website project and upload them to temporary public storage.
// lighthouserc.jsmodule.exports = { ci: { recopilar: { staticDistDir: './public', }, upload: { target: 'temporal-public-storage', }, },};
Heci.collect
The object provides several options for controlling how Lighthouse CI collects test reports. HestaticDistDir
is used to indicate the location of your static HTML files, for example,Hugobuild apublic
directory,jekyllput your build files in a_place
directory, and so on. All you need to do is update thestaticDistDir
option for wherever your building is located. When Lighthouse CI runs, it starts a server that can run the tests accordingly. Upon completion of the test, the server will automatically shut down.
If your project requires the use of a custom server, you can enter the command used to start the server via theiniciarServerCommand
property. When using this option, you must also specify the URLs to test via theURL
option. The custom server you specified must be able to serve this URL.
module.exports = { ci: { recopilar: { startServerCommand: 'npm run server', url: ['http://localhost:4000/'], }, upload: { target: 'temporal-public-storage', } ,},};
When Lighthouse CI runs, it runs theserver
command and take care of himto hear
oa list
string to determine if the server has started. If it doesn't detect this string after 10 seconds, it assumes the server has started and continues with the test. Then run Lighthouse three times on each URL in theURL
training. After the test run is complete, it shuts down the server process.
You can configure both the default sequence to watch and the timeout duration via thestartServerReadyPattern
ystartServerReadyTimeout
options respectively. If you want to change the number of times Lighthouse runs on each URL, use thenumber of runs
property.
// lighthouserc.jsmodule.exports = { ci: { collect: { startServerCommand: 'npm run server', url: ['http://localhost:4000/'], startServerReadyPattern: 'Server is running on PORT 4000 ', startServerReadyTimeout : 20000 // milissegundos numberOfRuns: 5, }, upload: { target: 'armazenamento público temporário', }, },};
Helook
property within theci.subir
The object is used to configure where Lighthouse CI loads results after a test is completed. Hetemporary public storage
The option indicates that the report will be uploaded to Google's cloud storage and will be retained for a few days. It will also be available to anyone who has the link, without the need for authentication. If you want more control over how reports are stored, see thedocumentation.
At this point, you should be ready to run the Lighthouse CI tool. Use the following command to launch the CLI. Will launch Lighthouse three times on the provided URLs (unless changed via thenumber of runs
option) and load the median result into the configured target.
lhci autorun
The output should be similar to what is shown below:
✅ The .lighthouseci/ directory is writable ✅ Configuration file found ✅ Chrome installation found ⚠️ GitHub token not set. -with-go/Run #1...done.Run #2...done.Run #3...done.Running Lighthouse 3 times at http://localhost:52195/custom-html5-video /Run # 1...done.Run #2...done.Run #3...done.Run Lighthouse Fact! ..success!Open the report at https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1606403407045-45763.report.htmlUploading median LHR from http://localhost:52195/custom-html5 - video/...success!Open report at https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1606403400243-5952.report.htmlSaving URL map to GitHub repository ayoisaiah/calouro.. .success !GitHub token not set, bypassing GitHub status check.Autorun completed.
The GitHub token message can be ignored for now. We'll set one up when it comes time to set up Lighthouse CI with a GitHub action. You can open the Lighthouse report link in your browser to see the median URL reach test results.

Assertion Configuration
Using the Lighthouse CI tool to run and collect Lighthouse reports works great, but we can go further and configure the tool to fail a build if the test results don't match certain criteria. The options that control this behavior can be configured through theclaim
property. Here is an excerpt showing an example configuration:
// lighthouserc.jsmodule.exports = { ci: { assertion: { preset: 'lighthouse: no-pwa', assertions: { 'categories: performance': ['error', { minScore: 0.9 }], 'categories: accessibility ': ['warn', {minimum score: 0.9 }], }, }, },};
Hepreset
The option is a quick way to configure Lighthouse assertions. There are three options:
lighthouse: all
: Claims that each audit received a perfect scoreheadlamp: recommended
– Asserts that all out-of-performance audits received a perfect score and warns when metric values fall below 90 pointsfaro: no-pwa
: The same asheadlamp: recommended
but without any of the PWA audits
you can use theaffirmations
object to override or extend the defaults, or create a custom set of assertions from scratch. The above configuration claims a benchmark score of 90 for theperformance
yaccessibility
categories. The difference is that failure of the former will result in a non-zero exit code, while the latter will not. The result of any Lighthouse audit can be confirmed, so there's a lot you can do here. Be sure to check thedocumentationto discover all available options.

You can also configure assertions against abudget.json
file. This can be created manually or generated viarendimientopresupuesto.io. Once you have your file, feed it into theclaim
object as shown below:
// lighthouserc.jsmodule.exports = { ci: { collect: { staticDistDir: './public', url: ['/'], }, assert: { budgetFile: './budget.json', }, load: { target: 'temporary public storage', }, },};

Running Lighthouse CI with GitHub Actions
A useful way to integrate Lighthouse CI into your development workflow is to generate new reports for every commit or pull request in your project's GitHub repository. this is whereGitHub Actionscome play.
To configure it, you must create a.github/workflow
directory at the root of your project. This is where all your project workflows will be placed. If you're new to GitHub Actions, you can think of a workflow as a set of one or more actions that run after an event fires (like when a new pull request is made to the repository). Sarah Drasner has a good manual onusing github actions.
mkdir -p .github/workflow
Then create a YAML file in.github/workflow
directory. You can name it whatever you like, as long as it ends with the.yml
o.yaml
extension. This file is where workflow settings for Lighthouse CI will be placed.
cd .github/workflowtouch lighthouse-ci.yaml
the content oflighthouse-us.yaml
The file will vary depending on the type of project. I will describe how I set it up for myselfsite do Hugoso you can adapt it to other types of projects. Here is my complete config file:
# .github/workflow/lighthouse-ci.yamlname: lighthouseon: [push] works: ci: executes: ubuntu-laststeps: -name: checkout code uses: actions/[email protected]com: token: ${{ secrets.PAT }} submodules: recursive - name: Setup Hugo uses: Peaceiris/[email protected]con: hugo-version: "0.76.5" extendido: true - name: Build site run: hugo - name: Use Node.js 15.x uses: actions/[email protected]com: node version: 15.x - name: Run Lighthouse CI run: | npm install -g @lhci/[email protected]lhci autorun
The above configuration creates a workflow calledfaro
consists of a single job (ci
) that runs on an Ubuntu instance and fires whenever code is pushed to any repository branch. The work consists of the following steps:
- Check out the repository where Lighthouse CI will run. Hugo uses submodules for its themes, so you need to make sure that all submodules in the repository are also checked out. If any submodules are in a private repository, you need to create a new onepersonal access tokenwith him
repository
scope enabled and then add it as a repository secret inhttps://github.com/<username>/<repo>/settings/secret
. Without this token, this step will fail if it finds a private repository.

- Install Hugo on the GitHub Action virtual machine so that it can be used to build the website. ThatHugo's configuration actionis what I used here. You can find other configuration actions inGitHub Stock Exchange.
- Build the site for a
public
paste through thehugo
domain. - Install and configure Node.js on the virtual machine viaconfiguration nodeAction
- Install the Lighthouse CI tool and run the
lhci autorun
domain.
After configuring the configuration file, you can commit and push the changes to your GitHub repository. This will activate the workflow you just added, provided its settings have been configured correctly. Go to the Actions tab in the project's repository to see the status of the workflow at its most recent commit.

If you click and expand theci
job, you will see logs for each job step. In my case everything went successfully but my assertions failed hence the failed status. As we saw when we ran the test locally, the results are sent to temporary public storage and you can view them by clicking on the appropriate link in the logs.

Configuring GitHub health checks
Currently, Lighthouse CI is configured to run as soon as code is pushed to the repository, either directly to a branch or via a pull request. Test status is displayed on the confirmation page, but you must click and expand the records to see full details, including links to the report.
You can set up a GitHubhealth check upso that the build reports are displayed directly in the pull request. To configure it, go toLighthouse CI GitHub application page, click the "Configure" option, install and authorize it in your GitHub account or in the organization that owns the GitHub repository you want to use. Then copy the app token given in the confirmation page and add it to your repository secrets with the name field set toLHCI_GITHUB_APP_TOKEN
.

The health check is now ready to use. You can test it by opening a new pull request or submitting a commit to an existing pull request.

Historical reporting and comparisons via Lighthouse CI server
Using the temporary public storage option to store your Lighthouse reports is a great way to start, but it's not enough if you want to keep your data private or longer. This is where the Lighthouse CI server can help. It provides a dashboard for exploring historical Lighthouse data and offers a great comparison UI for finding differences between builds.

To use Lighthouse CI Server, you must deploy it on your own infrastructure. Detailed instructions and recipes for deploying to Heroku and Docker can be found here.a GitHub.
Conclusion
When configuring your configuration, it's a good idea to include a few different URLs to ensure good test coverage. For a typical blog, you definitely want to include the homepage, one or two posts representative of the site's content type, and other important pages.
While we haven't covered the full scope of what the Lighthouse CI tool can do, I hope this article will not only help you get started using it, but also give you a good idea of what else it can do. Thanks for reading and happy coding!
FAQs
How to run lighthouse programmatically? ›
One of the simplest ways to run Lighthouse is through Chrome's DevTools Lighthouse panel. If you open your site in Chrome and then open Chrome's DevTools, you should see a “Lighthouse” tab. From there, if you click “Generate Report”, you should get a full report of your site's quality metrics.
Why use Lighthouse CI? ›You give Lighthouse a URL to audit, 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. You can also use Lighthouse CI to prevent regressions on your sites." As the results of my Powerboard audit show, Lighthouse is very easy to use.
What is lighthouse vs lighthouse CI? ›A single Lighthouse report provides a snapshot of a web page's performance at the time that it is run; Lighthouse CI shows how these findings have changed over time. This can be used to identify the impact of particular code changes or ensure that performance thresholds are met during continuous integration processes.
How can I improve my Lighthouse performance score? ›- Eliminate Render-Blocking Resources.
- Remove (or Reduce) Unused JavaScript Files.
- Reduce Time to First Byte (TTFB) and Server Response Times.
- Minimize Main Thread Work.
- Reduce Javascript Execution Time (Manually and With Plugins)
- Defer Offscreen Images (With and Without Plugins)
- Remove Unused CSS With and Without Plugins.
Best Practices
Lighthouse analyzes whether HTTPS and HTTP/2 are used, checks to see whether resources come from secure sources and assesses the vulnerability of JavaScript libraries. Other best practices look at secure database connections and avoiding the use of non-secure commands, such as document.
Performance is about measuring how quickly a browser can assemble a webpage. Lighthouse uses a web browser called Chromium to build pages and runs tests on the pages as they're built. The tool is open-source (meaning it is maintained by the community and free to use).
Is Lighthouse a good tool? ›Lighthouse is a great tool if it is used in the right way. You can (and should) use it to get a general sense of the performance of your website. No other tool will give you so much ready-to-process information with just a few clicks.
Does Lighthouse performance score affect SEO? ›Every webpage that is crawled by a search engine is evaluated with a score from 5 categories: Performance, Accessibility, Best Practices, SEO and PWA. This is given a score between 0 – 100. The better your lighthouse score is will affect how high up your webpage will appear on a search engine.
Is lighthouse still relevant? ›While lighthouses still guide seafarers, nowadays, the Global Positioning System (GPS), NOAA's nautical charts, lighted navigational aids, buoys, radar beacons, and other aids to navigation effectively warn mariners of dangerous areas and guide them to safe harbors.
What is an acceptable lighthouse score? ›To provide a good user experience, sites should strive to have a good score (90-100). A "perfect" score of 100 is extremely challenging to achieve and not expected. For example, taking a score from 99 to 100 needs about the same amount of metric improvement that would take a 90 to 94.
What are 2 types of lighthouses? ›
There are two types of lighthouses: ones that are located on land, and ones that are offshore. Offshore Lighthouses are lighthouses that are not close to land. There can be a number of reasons for these lighthouses to be built. There can be a shoal, reef or submerged island several miles from land.
How to get 100 on Lighthouse? ›...
Table of Contents
- Defer unused CSS. ...
- Defer offscreen images.
- Add the Preconnect tag.
- Eliminate render-blocking resources. ...
- Testing changes in a Staging server.
- Measure Core Web Vitals.
- Identify where you can improve on Web Vitals. Identify the Largest Contentful Paint element. Preload late-discovered images to improve LCP. Lazy loading offscreen images and avoiding this for LCP. Identify CLS contributions.
Your Lighthouse score is a weighted average of several performance metrics based on how your site appears to visitors. Your performance score will be between 0 and 100, with higher scores being better. Scores are color-coded: 0 – 49 (red): Poor.
How can we solve the lighthouse problem? ›Since we are told that the lighthouse can be seen from up to 32 km, CBA is a right-angle. By the Pythagorean theorem, 6371^2+32^2=(6371+h)^2=6371^2+2(6371)h+h^2, which simplifies to h^2 + 2(6371)h = 32^2, which in turn can be solved by the quadratic formula: h=\frac{-12742\pm\sqrt{12742^2-4(1)(-(32^2)}}{2} = .
What is the most important part of a lighthouse? ›3 Lantern Room: The lantern room is the most important room in a lighthouse because that is where the lighthouse beacon (or light) is located. The walls of the lantern room are made of glass so the light can be seen at night.
When was the best time to use lighthouse? ›Undoubtedly the best time for lighthouse photography is the half-light around dusk and dawn. At these times, the light is in operation, but the surrounding landscape is not completely dark, which makes exposures straightforward. The image below was a 40 second exposure at ISO 100 and f/11.
What is the best approach for measuring performance? ›The first step is to identify the objectives which the organization wants to achieve. The second step measures how well these objectives are made. While the third step involves how effective are they in evaluating employee performance. Finally, the last step gives feedback to the employees.
What is the best way to measure performance? ›- Graphic rating scales. A typical graphic scale uses sequential numbers, such as 1 to 5, or 1 to 10, to rate an employee's relative performance in specific areas. ...
- 360-degree feedback. ...
- Self-Evaluation. ...
- Management by Objectives (MBO). ...
- Checklists.
Graphic rating scales, management by objectives and forced ranking are three methods used to measure employee performance.
What are the drawbacks of Lighthouse? ›
Lighthouse is a synthetic test and must guess what your website's average user looks like. It can't tell you which pages are slow for your real production users or what kind of experience they are having. It can't tell you which pages are the most important or the most trafficked by your users.
Does Google use Lighthouse? ›Google has recently increased emphasis on-page experience, including adding a new set of Core Web Vital signals. The signals break down how a user experiences your page, and you can see how your website performs in this area through Lighthouse.
Is Lighthouse owned by Google? ›Google Lighthouse is developed by Google and aims to help web developers. Recent versions of Google Lighthouse offer insights into how to optimize the Core Web Vitals metrics, as announced by Google engineer Addy Osmani in 2021.
Does Google use Lighthouse for ranking? ›Since Google doesn't use the Lighthouse scores that are calculated with lab data, it relies on field data gathered from real visitors. If a site isn't getting much traffic then Google won't have enough field data to calculate its Core Web Vitals scores.
How do I improve my Lighthouse performance next JS? ›- Introduction to SEO.
- Crawling and Indexing.
- Rendering and Ranking.
- Performance & Core Web Vitals.
- Improving your Core Web Vitals. Lighthouse. Dynamic Imports. Dynamic Imports for Components. Optimizing Fonts. Optimizing Third-Party Scripts.
- Monitoring your Core Web Vitals.
"Lighthouse performance scores will change due to inherent variability in web and network technologies, even if there hasn't been a code change. "
What replaced the lighthouse? ›With the introduction of automated electric beacons, the lighthouse keeper became all but obsolete. In addition, modern satellite-based navigational systems that can be installed on ships of all sizes have replaced the lighthouse as a primary navigational aid.
How long does lighthouse last? ›The Lighthouse | |
---|---|
Running time | 109 minutes |
Countries | United States Canada |
Language | English |
Budget | $11 million |
According to Lighthouse Directory, there are more than 18,600 lighthouses worldwide.
How do you analyze a Lighthouse report? ›- Download Google Chrome for Desktop.
- In Google Chrome, go to the URL you want to audit. You can audit any URL on the web.
- Open Chrome DevTools.
- Click the Lighthouse tab. To the left is the viewport of the page that will be audited. ...
- Click Analyze page load. ...
- Click Run audit.
Does Lighthouse use cache? ›
By default, Lighthouse will look for a field of type ID on the parent to generate the key for a field with @cache.
How can I improve my mobile Lighthouse score? ›- While this is part of image optimization, it's important to flag this task as an essential step for Lighthouse Scores. ...
- They also provide context to site crawlers, so this optimization improves both SEO and Accessibility scores.
An engineering feat, Phare du Creach is one of the most powerful lighthouses in the world. Situated in the pretty French coastal town of Ushant, the black and white striped construction has been in operation since 1863. Every ten seconds, the lighthouse sends out two flashes which can be seen up to thirty miles away.
Why is it called a lighthouse? ›Lighthouse is a combination of the words 'light', from the Proto-Indo-European root 'leuk' meaning 'brightness', and 'house', from the Proto-Germanic 'husan' meaning 'dwelling'. As it refers to a structure built on rock near the sea used in ship navigation, the word lighthouse in English dates back to the 1620s.
What do you call someone who works in a lighthouse? ›A lighthouse keeper tends and cares for a lighthouse, helping guide ships and boats on major waterways. They often work with the lens and light functionality, though lighthouse keepers were even more essential when oil lamps powered the devices.
How do I run a Lighthouse command line? ›- Installation: install Chrome.
- Run it: open Chrome DevTools, select the Lighthouse panel, and hit "Generate report".
- Installation: install the extension from the Chrome Web Store.
- Run it: follow the extension quick-start guide.
Lighthouse is an open-source, automated tool for improving the quality of web pages. You can run it against any web page, public or requiring authentication.
Can we automate Lighthouse? ›Execute your automated lighthouse testing audits.
To run your automated Lighthouse tests, just configure your test run options with 'Audit' as your test category and 'Lighthouse' as your auditing tool of choice.
Go to Measure page and enter the URL to run the audit. It will take a few seconds, and you should see the detailed reporting with the overall scoring. Results also show the success metrics test for the passed audits and work on those needs attention.
What is a good lighthouse score? ›To provide a good user experience, sites should strive to have a good score (90-100). A "perfect" score of 100 is extremely challenging to achieve and not expected. For example, taking a score from 99 to 100 needs about the same amount of metric improvement that would take a 90 to 94.
Are lighthouses still used? ›
Though numerous lighthouses still serve seafarers, modern electronic aids to navigation play a larger role in maritime safety in the 21st century. Lighthouses and beacons are towers with bright lights and fog horns located at important or dangerous locations.
How to improve performance of Angular application in lighthouse? ›Reduce initial server response time
The angular bundle can be compressed and enable . gz (gZip). While the browser requests for any new path or page, the server will serve the gzipped file and reduce the loading time. For that, I have used a custom webpack to create compressed files.
Þrídrangaviti Lighthouse (transliterated as Thridrangaviti) is a lighthouse 4.5 miles (7.2 kilometres) off the southwest coast of Iceland, in the archipelago of Vestmannaeyjar, often described as the most isolated lighthouse in the world.
Is lighthouse a good tool? ›Lighthouse is a great tool if it is used in the right way. You can (and should) use it to get a general sense of the performance of your website. No other tool will give you so much ready-to-process information with just a few clicks.
Is lighthouse owned by Google? ›Google Lighthouse is developed by Google and aims to help web developers. Recent versions of Google Lighthouse offer insights into how to optimize the Core Web Vitals metrics, as announced by Google engineer Addy Osmani in 2021.
Does Lighthouse have an API? ›The Lighthouse Metrics API gives you access to a scalable way of creating Lighthouse reports and getting reliable performance metrics.
How to automate Lighthouse in selenium? ›- While on the desired web page.
- Click on Chrome Extension button and select Lighthouse extension.
- In the Lighthouse extension pop up displayed Click on "Generate Report" button.
...
Table of Contents
- Defer unused CSS. ...
- Defer offscreen images.
- Add the Preconnect tag.
- Eliminate render-blocking resources. ...
- Testing changes in a Staging server.
The three metrics represented by Core Web Vital are part of Lighthouse performance scoring. Largest Contentful Paint, Total Blocking Time, and Cumulative Layout Shift comprise 70% of Lighthouse's weighted performance score. The scores you'll see for CWV in Lighthouse result from emulated tests.