The OnPage Lighthouse API now supports a set of new parameters for browser simulation. You can now customize the browser environment used during Lighthouse audits to better reflect real-world device and network conditions.
What’s new
We added seven new parameters that allow you to set specific browser conditions for a Lighthouse audit, from a custom user agent to a network throttling profile:
custom_user_agent– sets a custom user agent string for the browser used during the audit.browser_screen_width– sets the browser’s screen width to emulate a specific device.browser_screen_height– sets the browser’s screen height to emulate a specific device.browser_screen_scale_factor– sets the browser’s device pixel ratio.browser_network_throttling_method– defines the throttling method used during the audit. Can take the following values:simulate– calculates estimated performance metrics without applying explicit throttling;devtools– explicitly applies the throttling settings specified inbrowser_network_throttlingandbrowser_cpu_throttling_multiplier;provided– uses the network conditions without applying throttling.browser_cpu_throttling_multiplier– sets the CPU throttling multiplier to a value between1and4. Applied only whenbrowser_network_throttling_methodis set todevtools.browser_network_throttling– sets the network throttling profile. Possible values:no_throttling,fast_4g,slow_4g,regular_3g,pc. Also applied only whenbrowser_network_throttling_methodis set todevtools.
How it works
All new parameters are optional, except browser_cpu_throttling_multiplier and browser_network_throttling, which are required when browser_network_throttling_method is set to devtools. To use them, include the relevant parameter in your Lighthouse endpoint request payload. The browser_network_throttling_method parameter controls overall throttling, while the screen and user agent parameters adjust the browser environment independently.
Why it matters
Lighthouse scores can vary significantly depending on the device and network conditions under which the audit runs. These new parameters allow you to run audits that better reflect the experience of a real user. For example, you can run custom scenarios to simulate slow or fast connection speeds, the use of low-performance devices, and leverage this data to improve your website’s technical SEO. Additionally, you can integrate browser simulation options into your custom analysis tools built upon the OnPage Lighthouse API.
Check out the updated documentation for the Lighthouse API to get started.