Skip to content

Conversation

@westonruter
Copy link
Collaborator

@westonruter westonruter commented May 26, 2025

After doing npm install, do:

npx puppeteer browsers install firefox

You can then specify that you want to benchmark with Firefox by passing firefox to the new --browser (-b) argument.

Note that network emulation and CPU throttling are not currently supported. Also, bypassing CSP is not supported so injecting the web-vitals.js script may not work if attempting to benchmark a site which is using a Content Security Policy.

Chrome

npm run research -- benchmark-web-vitals -u https://example.org/ -o md -b chrome
URL https://example.org/
Success Rate 100%
FCP (median) 211.3
LCP (median) 211.3
TTFB (median) 181.4
LCP-TTFB (median) 29.9

Firefox

npm run research -- benchmark-web-vitals -u https://example.org/ -o md -b firefox
URL https://example.org/
Success Rate 100%
FCP (median) 339
LCP (median) 339
TTFB (median) 282
LCP-TTFB (median) 57

@westonruter westonruter added the enhancement New feature or request label May 26, 2025
}
const page = await browser.newPage();
await page.setBypassCSP( true ); // Bypass CSP so the web vitals script tag can be injected below.
if ( 'firefox' !== params.browser ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this conditional, I get an error:

CDP support is required for this feature. The current browser does not support CDP.

@westonruter westonruter force-pushed the add/firefox-benchmark-web-vitals branch from b70109f to 0d07a0e Compare May 26, 2025 16:17
Comment on lines -628 to +654
await page.click( 'body', {
offset: { x: -500, y: -500 },
} );
await page.mouse.click( 0, 0 );
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change because when using the original, Firefox complains with:

Error: Protocol error (input.performActions): move target out of bounds Move target (-500, -1606) is out of bounds of viewport dimensions (960, 700)

When I try changing the coordinates to 0,0 then the error is:

Error: Protocol error (input.performActions): move target out of bounds Move target (0, -1106) is out of bounds of viewport dimensions (960, 700)

Using negative coordinates with page.mouse.click() also results in an error:

Error: Protocol error (input.performActions): move target out of bounds Move target (-500, -500) is out of bounds of viewport dimensions (960, 700)

So this is why I changed it to 0,0.

@westonruter westonruter force-pushed the add/firefox-benchmark-web-vitals branch from 444c8e5 to 10912a5 Compare May 26, 2025 16:28
Comment on lines +266 to +270
if ( params.browser === 'firefox' ) {
throw new Error(
'Network emulation is not currently available in Firefox.'
);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this conditional, I get an error:

UnsupportedOperation
    at BidiPage.emulateNetworkConditions (file:///Users/westonruter/repos/wpp-research/node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Page.js:576:23)
    at benchmarkURL (file:///Users/westonruter/repos/wpp-research/cli/commands/benchmark-web-vitals.mjs:591:16)
    at async handler (file:///Users/westonruter/repos/wpp-research/cli/commands/benchmark-web-vitals.mjs:465:42)
    at async Command.<anonymous> (file:///Users/westonruter/repos/wpp-research/cli/run.mjs:79:4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants