This example shows how to write a custom Lighthouse audit
-
searchable-gatherer.js - a Gatherer that collects
window.myLoadMetrics.searchableTime
from the context of the page. -
searchable-audit.js - an Audit that tests whether or not
window.myLoadMetrics.searchableTime
stays below a 4000ms threshold. In other words, Lighthouse will consider the audit "passing" in the report if the search box initializes within 4s. -
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, passes with the same name are merged together, all other arrays will be concatenated, and primitive values will override the defaults.
Run Lighthouse with the custom audit in terminal
npm run audit
See Lighthouse Architecture for information on terminology and architecture.