- Docs
- Parameters
- trigger
trigger
- Recordings
Start a recording when the page is ready
How it works
Section titled “How it works”trigger decides when a recording starts capturing and running actions.
The page loads and gets ready first, including fonts, images, and the scroll preload. Then the recording waits for the trigger. Nothing before the trigger is in the video, and the wait doesn’t count toward duration_ms.
If the trigger times out, the recording fails with the trigger_timeout error before it starts.
Schema
Section titled “Schema”trigger is an object. Its type field selects one of the trigger types below:
type |
Starts when | Fails when |
|---|---|---|
immediate |
The page is ready | — |
element_visible |
An element matching selector is visible |
timeout_ms runs out |
function_call |
The page calls window.RecordingReady() |
timeout_ms runs out |
immediate
Section titled “immediate”| Field | Type | Default | Description |
|---|---|---|---|
type |
String |
Required. immediate |
element_visible
Section titled “element_visible”| Field | Type | Default | Description |
|---|---|---|---|
type |
String |
Required. element_visible |
|
selector |
String |
Required. CSS selector for the element to wait for. | |
timeout_ms |
Integer |
1000 |
Maximum wait in milliseconds. Minimum 100. The maximum depends on your plan. |
function_call
Section titled “function_call”| Field | Type | Default | Description |
|---|---|---|---|
type |
String |
Required. function_call |
|
timeout_ms |
Integer |
1000 |
Maximum wait for window.RecordingReady() in milliseconds. Minimum 100. The maximum depends on your plan. |
The maximum timeout_ms is 10,000 on Startup, 30,000 on Pro plans, and 50,000 on Scale plans.
Default behavior
Section titled “Default behavior”Defaults to { "type": "immediate" }. The recording starts as soon as the page is ready.
When to use it
Section titled “When to use it”element_visible: single-page apps, dashboards, and other pages that render their main content after load.function_call: pages you control, where you know exactly when everything is ready. This is the recording version ofrender_when_ready.
Example usage
Section titled “Example usage”Wait for a chart to appear
Section titled “Wait for a chart to appear”{ "url": "https://example.com/dashboard", "duration_ms": 8000, "trigger": { "type": "element_visible", "selector": "#dashboard .chart", "timeout_ms": 8000 }, "actions": [{ "type": "simple_scroll" }]}Signal from your page
Section titled “Signal from your page”{ "html": "<canvas id='chart'></canvas><script src='https://example.com/chart.js'></script>", "duration_ms": 5000, "duration_mode": "fixed", "trigger": { "type": "function_call", "timeout_ms": 5000 }, "actions": [{ "type": "execute_javascript", "script": "window.animateChart();" }]}Your page calls window.RecordingReady() once it’s ready to record:
<script> loadChartData().then(data => { drawChart(data); window.RecordingReady(); });</script>Need help?
Talk to a human. Email support@htmlcsstoimage.com and we’ll help you get started.