Google Lighthouse is a powerful tool for optimizing your website's performance. It provides a comprehensive audit of your site's speed, accessibility, and best practices, giving you a clear picture of where improvements can be made.
Lighthouse is built into Chrome DevTools, making it easy to access and run audits on your site. You can also use the Lighthouse extension to audit your site from anywhere.
Running a Lighthouse audit is simple: just open Chrome DevTools, navigate to the Lighthouse tab, and click "Generate Report." The audit will analyze your site's performance and provide a score out of 100.
The audit will also highlight specific areas for improvement, such as optimizing images, minifying CSS and JavaScript files, and improving page loading times.
Getting Started
To get started with Google Lighthouse, you'll need to install the Lighthouse CLI on your operating system of choice. This can be Windows, macOS, or Ubuntu.
First, ensure you have Google Chrome installed, as well as a package manager like npm (Node Package Manager). The latest versions of Node.js require a NODE_MAJOR value of at least 18, which is currently met in Node.js versions 20 and 21.
To make the bash file executable, use the chmod command. This is a crucial step in setting up your environment for Lighthouse CLI.
For Ubuntu OS, you'll need super user access to install Lighthouse CLI. This will allow you to run Lighthouse commands in your desired directories.
Running Lighthouse
Running Lighthouse is a straightforward process that can be done in a few different ways. You can run Lighthouse in Chrome DevTools, as a Chrome extension, or programmatically using the Node module.
To run Lighthouse in Chrome DevTools, download Google Chrome for Desktop, open Chrome, and go to the URL you want to audit. Then, open Chrome DevTools, click the Lighthouse tab, and click Analyze page load. Leave all the audit categories enabled and click Run audit.
You can also run Lighthouse as a Chrome extension by installing it from the Chrome Webstore. Once installed, go to the page you want to audit, click Lighthouse next to the address bar, and select Generate report.
If you want to run Lighthouse programmatically, you can use the Node module. However, this requires Node 18 LTS or later, and you can install it by default.
Here are some ways to run Lighthouse in Chrome DevTools:
- Navigation: reload the page and grade performance, accessibility, and SEO.
- Timespan: collect data on a page that is already open, for example measuring how long a page interaction takes.
- Snapshot: analyze accessibility and SEO of the current page state.
Note that using DevTools throttling is less reliable than using a dedicated page speed tool.
Configuring Lighthouse
Configuring Lighthouse is a great way to get specific results from your audits. You can limit audit specific categories in Lighthouse CLI by using a command that specifies one or more categories.
To run Lighthouse CLI for a specific goal, you can use the command to limit or specify one or more categories. This is especially useful when there's no need for other auditing categories' reports.
If you want to skip or exclude some auditing items, you can use a command that allows you to decide about each audit to be run. This gives you more control over the auditing process and helps you focus on what's important.
Integrate
Integrate Lighthouse into your products or services, and we're happy to have you on board. We encourage everyone to use Lighthouse to improve web performance.
To integrate Lighthouse properly, refer to the Guidelines and Brand Assets. This will ensure you're using our brand correctly while offering Lighthouse as part of your offerings.
If you're looking for non-web performance services that integrate Lighthouse, here are some options:
Options
You can customize Lighthouse's behavior by using various CLI options. One way to do this is by using the --gather-mode (-G) and --audit-mode (-A) CLI flags to run a subset of Lighthouse's lifecycle.
These flags allow you to specify how you want Lighthouse to behave, giving you more control over the auditing process. You can use them to save time and resources by running only the audits that are relevant to your needs.
Lighthouse CLI reports can be saved to a custom path using a specific command. This is useful if you need to save reports in a different location than the default.
You can change the Lighthouse CLI report saving path by using the following command: `command to change report saving path`.
Lighthouse audit is done with the mobile device preset by default, but you can change the device to desktop or adjust the viewport dimension using specific commands.
You can change the Lighthouse CLI auditing device by using the following commands: `command to change device to desktop` and `command to change viewport dimension`.
Lighthouse auditing is divided into 5 categories: Performance, Accessibility, Best practices, SEO, and Progressive Web App (PWA). You can check the auditable items in each category using a specific command.
Here are the 5 Lighthouse auditing categories:
- Performance
- Accessibility
- Best practices
- SEO
- Progressive Web App (PWA)
You can limit or specify one or more specific Lighthouse auditing categories by using a command that includes the category name. This is useful if you only need to run audits for a specific goal.
You can limit audit specific categories in Lighthouse CLI by using the following command: `command to limit categories`.
You can decide which audits to run and which to skip or exclude by using specific commands. This gives you more control over the auditing process and allows you to save time and resources.
You can limit and exclude audits in Lighthouse CLI by using the following command: `command to limit and exclude audits`.
Changing Report Saving Path
You can change the Lighthouse CLI report saving path using a specific command.
To access the report, you'll see a path for the audit report after running the Lighthouse command. This path can be used to access the report on your device.
The command to change the saving path is quite straightforward.
Here are the steps to change the saving path:
- Run the command to see the report in the browser after the audit process is finished.
- Use the command below to change the Lighthouse CLI report saving path:
Customizing Report Format
Customizing Report Format is a breeze with Lighthouse. You can save the report in up to three formats including HTML, CSV, and JSON by using the command below.
To save the report in the desired format, you need to use the command that includes the format you want, such as HTML, CSV, or JSON.
Advanced Topics
Using the Node CLI offers more flexibility in configuring and running Lighthouse. It's ideal for users who want to automate Lighthouse or need more advanced usage.
Lighthouse requires Node 18 LTS (18.x) or later, so make sure your environment meets this requirement. This ensures a smooth experience with the Node CLI.
To install Lighthouse, you can control the output format by passing flags. This allows you to customize the report to suit your needs.
Running Node Module Programmatically
Running Node Module Programmatically is a powerful way to automate tasks and integrate Lighthouse into your workflow.
You can run Lighthouse programmatically as a Node module. To do this, see the Using programmatically example for more information.
Lighthouse requires Node 18 LTS (18.x) or later to run programmatically. This ensures a stable and efficient execution of the module.
The Node CLI provides a flexible way to configure and report Lighthouse runs. Users who want more advanced usage or automated runs should use the Node CLI.
Stack Packs
Stack Packs are a game-changer for web developers. They allow Lighthouse to provide relevant and actionable advice based on the specific technologies used to build a web page.
Developers use a variety of tools to build their web pages, including backend technologies, content management systems, and JavaScript frameworks. Instead of giving general recommendations, Lighthouse uses stack packs to detect the platform used and display specific stack-based recommendations.
These recommendations are defined and curated by experts from the community. To contribute a stack pack, you can review the Contributing Guidelines.
Stack packs can help you improve your web page's performance, accessibility, and SEO. They're a great way to get actionable advice tailored to your specific needs.
Here are some examples of stack packs:
By using stack packs, you can get the most out of Lighthouse and improve your web page's performance and user experience.
Plugins
Plugins are a powerful way to extend the functionality of Lighthouse for specific needs.
You can leverage the data Lighthouse collects to create new audits.
Lighthouse plugins are node modules that implement a set of checks to be run by Lighthouse and added to the report as a new category.
Some examples of plugins include lighthouse-plugin-field-performance, which adds real-user performance metrics for the URL using the data from Chrome UX Report.
Another plugin is lighthouse-plugin-publisher-ads, a tool to improve ad speed and overall quality through a series of automated audits.
lighthouse-plugin-crux is a plugin that quickly gathers real-user-metrics data from the Chrome UX Report API.
Here are some examples of Lighthouse plugins:
- lighthouse-plugin-field-performance
- lighthouse-plugin-publisher-ads
- lighthouse-plugin-crux
assistant
As an assistant, I've had the chance to explore various ways to run Lighthouse, and I'm excited to share my findings with you.
You can run Lighthouse directly from Chrome DevTools, which is a convenient option for quick audits.
To do this, simply open Chrome, navigate to the URL you want to audit, open Chrome DevTools, and click on the Lighthouse tab.
Lighthouse also offers a Node module that can be run programmatically, giving you more flexibility in how you configure and report your audits.
If you're looking for even more advanced usage, consider using the Node CLI, which provides the most flexibility in configuring and reporting Lighthouse runs.
Here are the minimum Node requirements for running Lighthouse: Node 18 LTS (18.x) or later.
To run Lighthouse using the Node CLI, you'll need to install it first, and then you can control the output format by passing flags.
If you're not comfortable with the command line, you can also use the Chrome extension, which offers similar functionality to the Lighthouse panel in Chrome DevTools.
The Chrome extension can produce a report as JSON or HTML, giving you flexibility in how you view and share your results.
To install the Chrome extension, simply head to the Chrome Web Store and follow the installation instructions.
Lighthouse is integrated directly into Chrome DevTools, making it easy to run audits and view results without leaving the browser.
To run Lighthouse in Chrome DevTools, simply open Chrome, navigate to the URL you want to audit, open Chrome DevTools, and select the Lighthouse panel.
Here are the basic steps to run Lighthouse in Chrome DevTools:
- Download Google Chrome for Desktop.
- Open Chrome, and go to the URL you want to audit.
- Open Chrome DevTools.
- Click the Lighthouse tab.
- Click Analyze page load.
- Click Run audit.
Troubleshooting
Troubleshooting can be a frustrating process, but understanding the differences between Lighthouse and CWV tests can help. Sometimes, the results of these tests can be striking.
Google Lighthouse is a tool that helps you identify performance and accessibility issues on your website. It provides a report with scores and recommendations for improvement, but the results may not always match those of CWV tests.
The differences between Lighthouse tests and CWV tests can be due to the way each tool measures performance and accessibility. Lighthouse tests are based on the Web Vitals metrics, which include metrics like First Contentful Paint (FCP) and Largest Contentful Paint (LCP).
You may be seeing striking differences between Lighthouse tests and CWV tests because of these different measurement methods. This can make it harder to identify the root cause of performance issues on your website.
Understanding Lighthouse Scores
The Lighthouse Performance score is made up of five individual website performance metrics, each contributing a certain percentage to the overall score. These metrics include Total Blocking Time, Largest Contentful Paint, Cumulative Layout Shift, First Contentful Paint, and Speed Index.
To get a green score of 90 or over, you need to perform well in these five areas. For example, to get a score of 90 for the Largest Contentful Paint metric, the metric value has to be below 2.5 seconds.
Here's a breakdown of the five metrics and their score contributions:
By understanding these metrics and how they contribute to the overall score, you can focus on improving your website's performance and getting those all-green scores.
Time to Interactive (TTI)
Time to Interactive (TTI) is a crucial metric that measures the load responsiveness of a page, indicating when it looks responsive but isn't yet. Its weightage is 15% in Lighthouse scores.
The best time for TTI is less than 3.8 seconds. This is the sweet spot where users can start interacting with your page without experiencing any significant delays. Any longer than that, and you risk frustrating your visitors.
Here's a breakdown of TTI scores and their corresponding color-coding:
To improve TTI, you can focus on optimizing your page for readiness interactions, reducing JavaScript execution time, and ensuring that your page is ready for user input.
How Is the Score Calculated?
The Lighthouse Performance score is a combination of five individual website performance metrics. Each metric is assigned a subscore based on its value.
Here's a breakdown of the metrics that make up the score: MetricScore ContributionWhat It MeasuresTotal Blocking Time30%Could a large amount of CPU processing on the page lead to slow user interactions?Largest Contentful Paint25%How quickly does the main page content show up?Cumulative Layout Shift25%Does page content move around after appearing and disorient the user?First Contentful Paint10%How quickly does the first bit of page content show up?Speed Index10%How long does it take for most of the page content to appear?
To get a score of 90 for the Largest Contentful Paint metric, the metric value has to be below 2.5 seconds.
Should You Worry About a Poor Score?
A poor Lighthouse score won't get you penalized by Google if your real visitor metrics are in the green.
However, you may still want to optimize your website further to provide a better experience for users with slower mobile devices and worse internet connections.
You can run a lab test with more typical settings for real users using tools like DebugBear and selecting the "Mobile Fast" config when setting up your page.
As long as your real visitor metrics are good, you can breathe a sigh of relief, but keep in mind that a slow Lighthouse score correlates with a slow experience for real users.
Optimizing your website can still help you rank higher in Google, so it's worth taking a closer look at your Lighthouse score and making some improvements.
Score Variance Between Runs
Lighthouse scores can vary between runs due to random variation in server response times, different content being loaded, and variation in background activity. This is because no two page loads are identical and have exactly the same load time.
For example, if your website loads 10s or 100s of resources, the servers involved may respond more quickly or slowly, affecting the Lighthouse result.
Different content, such as ads or frequently-changing content, can also cause page speed to vary. This is because the content being loaded can affect the load time.
Background activity, like other websites open in the background or the computer performing other tasks, can also impact Lighthouse results.
To put it simply, Lighthouse scores are only a snapshot of a single load of your website, and they're not always comparable across different environments.
Here are some reasons why Lighthouse scores can vary between runs:
- Random variation in server response times
- Different content being loaded
- Variation in background activity
Additionally, Lighthouse scores collected in different environments, such as on PageSpeed Insights and on your own computer, may not be directly comparable due to differences in hardware and location.
Improving Performance
Lighthouse automatically identifies potential improvements and ranks them by the estimated savings on your page load time. You can find these opportunities in the Lighthouse performance category, specifically in the opportunities section.
To optimize your Lighthouse score, focus on the following areas: Slow Server Response time: Optimize your server or use a nearby CDN, establish third-party connections early.Render Blocking JavaScript & CSS: Minify CSS and JS, remove unused CSS and JS, remove inline CSS.Compress Image Size and Video Size: Preload important resources early, minimize critical JavaScript.
The best time for Largest Contentful Paint (LCP) is under 2.5 seconds, and for First Contentful Paint (FCP) and Speed Index (SI) is less than 2 seconds and 4.2 seconds, respectively.
Web Perf Services
DebugBear is a tool that allows you to continuously monitor your website's performance. It helps marketing and development teams track and optimize their website speed and Core Web Vitals.
You can set up continuous monitoring for Lighthouse scores and Core Web Vitals with DebugBear. This will give you a detailed analysis of your website's performance over time.
With DebugBear, you can see how your Lighthouse scores change over time. This will help you identify areas where your website needs improvement.
Here are some benefits of using DebugBear:
- See how your Lighthouse scores change over time.
- Access detailed analysis that goes beyond the Lighthouse report.
- Get alerted to and understand score regressions.
- Show off the improvements that your team has implemented.
- Monitor Google CrUX metrics and collect custom real user data.
First Paint
First Paint is a crucial aspect of website performance. It's the time it takes for the first image or text to become visible on the screen.
The best time for First Contentful Paint (FCP) is less than 2 seconds, which is considered fast. This is because FCP has a weightage of 15% to performance.
If your FCP time is between 0 and 2 seconds, you're doing great – it's like getting a green light! According to HTTPS Archive, this corresponds to an FCP Score of 75-100.
On the other hand, if your FCP time is 4 seconds or more, it's a red flag. This means your FCP Score is likely between 0-49, indicating a slow performance.
Here's a quick reference chart to help you gauge your FCP performance:
Speed Index (SI)
The Speed Index (SI) is a key performance metric that measures how much time is visible during load. It's weighted at 15% and the best time for SI is less than 4.2 seconds.
SI time is color-coded to quickly identify performance issues. Here's a breakdown of the color-coding system:
If your SI time falls within the 0-4.3 range, you can expect a fast user experience, with an FCP score of 75-100. On the other hand, if your SI time is above 5.8 seconds, you're likely to see a slow user experience, with an FCP score of 0-49.
How to Improve Your Score
To improve your Lighthouse performance score, start by checking the opportunities section of the Lighthouse performance category. This is where Lighthouse automatically identifies potential improvements and ranks them by the estimated savings on your page load time.
One of the key areas to focus on is the Largest Contentful Paint (LCP), which represents the user perception of the loading experience. Aim for an LCP time of under 2.5 seconds for the best results.
Here's a breakdown of what can impact LCP:
Slow server response times, render-blocking JavaScript and CSS, and oversized images and videos can all contribute to poor LCP. To address this, optimize your server, use a nearby CDN, and establish third-party connections early.
Another important metric to focus on is the First Contentful Paint (FCP), which measures the time it takes for the first image or text to be visible. Aim for an FCP time of under 2 seconds for the best results.
To improve your FCP, minify CSS and JS, remove unused CSS and JS, and remove inline CSS. Compress image and video sizes, and preload important resources early.
Frequently Asked Questions
How do I access Google Lighthouse?
To access Google Lighthouse, click Lighthouse in the Chrome address bar or extension menu, and follow the prompts to generate a report. This will launch the Lighthouse audit tool, allowing you to analyze and improve your website's performance.
Is Google Lighthouse free?
Yes, Google Lighthouse is a free tool. It offers powerful insights to help improve your website's performance without any cost.
Sources
- https://developer.chrome.com/docs/lighthouse/overview
- https://www.oxyplug.com/optimization/how-to-install-and-use-google-lighthouse-cli/
- https://github.com/GoogleChrome/lighthouse
- https://www.xenonstack.com/blog/google-lighthouse-tool
- https://www.searchenginejournal.com/website-speed-google-lighthouse-debugbear-spa/496707/
Featured Images: pexels.com