Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 2.23 KB

architecture.md

File metadata and controls

38 lines (26 loc) · 2.23 KB

Architecture

Some incomplete notes

Lighthouse Architecture

Components & Terminology

  • Driver - Interfaces with Chrome Debugging Protocol (API viewer)
  • Gatherers - Uses Driver to collect information about the page. Minimal post-processing.
    • Artifacts - output of a gatherer
  • Audits - Using the Artifacts as input, Audits evaluate a test and assign pass/fail/scoring.
    • Computed Artifacts - Generated on-demand from artifacts, these add additional meaning, and are often shared amongst multiple audits.
  • Categories - Grouping audit results into a user-facing section of the report (eg. Best Practices). Applies weighting and overall scoring to the section.

Protocol

  • Interacting with Chrome: The Chrome protocol connection maintained via WebSocket for the CLI chrome.debuggger API when in the Chrome extension.
  • Event binding & domains: Some domains must be enable()d so they issue events. Once enabled, they flush any events that represent state. As such, network events will only issue after the domain is enabled. All the protocol agents resolve their Domain.enable() callback after they have flushed any pending events. See example:
// will NOT work
driver.sendCommand('Security.enable').then(_ => {
  driver.on('Security.securityStateChanged', state => { /* ... */ });
})

// WILL work! happy happy. :)
driver.on('Security.securityStateChanged', state => { /* ... */ }); // event binding is synchronous
driver.sendCommand('Security.enable');

Audits

The return value of each audit takes this shape.

The details object is parsed in report-renderer.js. View other audits for guidance on how to structure details.