Evaluate JavaScript
Execute JavaScript code in the page context before rendering to manipulate the DOM or wait for dynamic content
The evaluate_js
parameter allows you to run JavaScript code in the page context before rendering occurs.
Overview
When rendering a webpage with dynamic content, you may need to manipulate the DOM, trigger actions, or wait for content to load. The evaluate_js
parameter lets you execute custom JavaScript code during the rendering process.
Parameter details
Allows you to run JavaScript code in the page context before rendering occurs
Usage
Behavior
The JavaScript expression is evaluated in the page context before rendering begins. If the expression returns a Promise, the rendering process will wait for the Promise to resolve before proceeding.
Use cases
This parameter is particularly useful for:
-
Loading dynamic content: Trigger actions that load additional content before capturing the page.
-
DOM manipulation: Modify page elements, styles, or attributes before rendering.
-
Waiting for conditions: Ensure specific elements or data are available before rendering.