We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0aea4fa commit 5d272c0Copy full SHA for 5d272c0
analyze.js
@@ -0,0 +1,32 @@
1
+import puppeteer from "puppeteer";
2
+import lighthouse from "lighthouse";
3
+import { URL } from "url";
4
+
5
+async function runLighthouse(url) {
6
+ const browser = await puppeteer.launch({
7
+ headless: true,
8
+ args: ["--remote-debugging-port=9222"],
9
+ });
10
11
+ const result = await lighthouse(url, {
12
+ port: 9222,
13
+ output: "html",
14
+ logLevel: "info",
15
16
17
+ await browser.close();
18
+ return result.lhr;
19
+}
20
21
+const url = process.argv[2];
22
+if (!url) {
23
+ console.error("❌ Please provide a URL");
24
+ process.exit(1);
25
26
27
+const result = await runLighthouse(url);
28
+console.log(
29
+ `✅ Performance score for ${url}: ${
30
+ result.categories.performance.score * 100
31
+ }`
32
+);
0 commit comments