Performance with Lighthouse
What is Lighthouse?
Meassures web pages performance, by reproducig certain conditions via settings.
- You can find documentation on its GitHub repo
- It can be run on Chrome DevTools via an extension
- You can also run it via CLI
Installation
1 | npm install -g lighthouse |
Run it
1 | lighthouse https://example.com/ |
Options
Logging
1
2--verbose #Displays verbose logging
--quiet #Displays no progress, debug logs or errorsConfiguration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32# Save the trace & devtools log to disk
--save-assets
# Prints a list of all available audits and exits
--list-all-audits
# Prints a list of all required trace categories and exits
--list-trace-categories
# Print the normalized config for the given config and options, then exit
--print-config
# Additional categories to capture with the trace (comma-delimited)
--additional-trace-categories
# The path to the config JSON
--config-path
# Custom flags
--chrome-flags
# The port to use for the debugging protocol.
--port # Use 0 for a random port
# Use a built-in configuration
--preset # choices: "full", "perf", "mixed-content"
# The hostname to use for the debugging protocol
--hostname # default: "localhost"
# Timeout in milliseconds
--max-wait-for-load #default: 45000
# Controls the emulated device form factor if not disabled
--emulated-form-factor #[choices: "mobile", "desktop", "none"]
# Enables error reporting, overriding any saved preference
--enable-error-reporting
# Opposite of the previous flag
--no-enable-error-reporting
# Collect artifacts from a connected browser and save to disk
--gather-mode, -G
# Process saved artifacts from disk, prevents -G from quit early
--audit-mode, -AOutput
1
2
3
4
5
6
7--output # Reporter for the results, [choices: "json", "html", "csv"]
--output-path #The file path to output the results. Use 'stdout' to write to stdout
# If using JSON output, default is stdout
# If using HTML or CSV output, default is a file in the working directory
# with a name based on the test URL and date
# Example: --output-path=./lighthouse-results.html
--view #Open HTML report in your browser
Configuration file example
1 | ; |