Tip: see Lighthouse Architecture for information on terminology and architecture.
This example shows how to write a custom Lighthouse audit that measures memory usage using the Chrome DevTools Protocol Memory.startSampling command. The audit fails if any memory sample exceeds 1 MB.
-
memory-gatherer.js - a Gatherer that collects memory sampling data from the browser.
-
memory-audit.js - an Audit that tests whether or not the memory usage stays below a 1MB threshold.
-
custom-config.js - this file tells Lighthouse where to find the gatherer and audit files, when to run them, and how to incorporate their output into the Lighthouse report. This example extends Lighthouse's default configuration.
Note: when extending the default configuration file, all arrays will be concatenated and primitive values will override the defaults.
Run Lighthouse with the custom audit by using the --config-path flag with your configuration file:
lighthouse --config-path=custom-config.js https://example.com