Lighthouse has an indepedent report renderer that takes the LHR (Lighthouse Result object) and creates a DOM tree of the report. It’s all done client-side.
Example standalone HTML report, delivered by the CLI: dbwtest-3.0.3.html
(View the source! 📖)
lighthouse-core/report/report-generator.js
is the current entry point. It compiles together the HTML string with everything required within it.
fs.readFileSync()
calls and replaces them with the stringified file content.lighthouse-core/report/html/
has everything required to create the HTML report.lighthouse-core/report/html/renderer
are all client-side JS files. They transform an LHR object into a report DOM tree. They are all executed within the browser.lighthouse-core/report/html/report-template.html
is where the client-side build of the DOM report is typically kicked off (with these four lines) However, see Current Uses.. below for more possibilities.innerHTML
is deliberately not used. The renderer relies on basic createElement
as well as multiple components defined in <template>
tags that are added via document.importNode()
and filled in via the querySelector
/textContent
combo.
Examples:
The renderer was designed to be portable across various environments.
renderer
files are rolled into the Chromium repo, and they execute within the DevTools context. The audits panel receives the LHR object from a WebWorker, through a postMessage
and then runs the renderer within DevTools UI, making a few simplifications.viewer.js
file. Same basic approach there.The details-element-polyfill
is pulled in to provide support for Microsoft Edge.