Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
export const untitled_blueZebra = (async () => {
// const { default: fs } = await import("npm:fs");
const { default: lighthouse } = await import("npm:lighthouse");
const { default: chromeLauncher } = await import("npm:chrome-launcher");
const chrome = await chromeLauncher.launch({ chromeFlags: ["--headless"] });
const options = {
logLevel: "info",
output: "html",
onlyCategories: ["performance"],
port: chrome.port,
};
const runnerResult = await lighthouse("https://www.trainor.com/", options);
// `.report` is the HTML report as a string
const reportHtml = runnerResult.report;
// fs.writeFileSync("lhreport.html", reportHtml);
console.log(reportHtml);
// `.lhr` is the Lighthouse Result as a JS object
console.log("Report is done for", runnerResult.lhr.finalDisplayedUrl);
console.log(
"Performance score was",
runnerResult.lhr.categories.performance.score * 100,
);
await chrome.kill();
})();
October 23, 2023