From 201b93cd273e4f56d4947f09de933e25982968b4 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 17 Feb 2023 10:54:15 -0800 Subject: [PATCH 1/2] Add CLS, FID, and INP. --- cli/commands/benchmark-web-vitals.mjs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/cli/commands/benchmark-web-vitals.mjs b/cli/commands/benchmark-web-vitals.mjs index 5e802aa..741c6e9 100644 --- a/cli/commands/benchmark-web-vitals.mjs +++ b/cli/commands/benchmark-web-vitals.mjs @@ -97,19 +97,31 @@ export async function handler( opt ) { } async function benchmarkURL( browser, params ) { - /* - * For now this only includes load time metrics. - * In the future, additional Web Vitals like CLS, FID, and INP should be - * added, however they are slightly more complex to retrieve through an - * automated headless browser test. - */ const metricsDefinition = { + CLS: { + listen: 'onCLS', + global: 'webVitalsCLS', + get: () => window.webVitalsCLS, + results: [], + }, FCP: { listen: 'onFCP', global: 'webVitalsFCP', get: () => window.webVitalsFCP, results: [], }, + FID: { + listen: 'onFID', + global: 'webVitalsFID', + get: () => window.webVitalsFID, + results: [], + }, + INP: { + listen: 'onINP', + global: 'webVitalsINP', + get: () => window.webVitalsINP, + results: [], + }, LCP: { listen: 'onLCP', global: 'webVitalsLCP', From f2bf15d3d834bb66effa14bf431cbf363cffb907 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 17 Feb 2023 11:06:41 -0800 Subject: [PATCH 2/2] Update documentation. --- cli/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/README.md b/cli/README.md index 6a1b382..971727e 100644 --- a/cli/README.md +++ b/cli/README.md @@ -126,7 +126,7 @@ benchmark-server-timing -f path/to/urls.txt -n 5 ### `benchmark-web-vitals` -Loads the provided URLs in a headless browser several times to measure median Web Vitals metrics for each URL. Currently the results cover load time metrics FCP, LCP, and TTFB. Including additional metrics is explored in a [follow up pull request](https://github.com/GoogleChromeLabs/wpp-research/pull/41). +Loads the provided URLs in a headless browser several times to measure median Web Vitals metrics for each URL. Currently the results cover metrics CLS, FCP, FID, INP, LCP, and TTFB. #### Arguments