Skip to content
HTML/CSS to ImageDocs

Limit how long the API waits before capturing your image

The max_wait_ms parameter sets a maximum time limit for waiting before the screenshot is taken. This is useful when pages load extra irrelevant content that you don’t need to wait for.

Minimum Maximum
500 ms 10000 ms (10 seconds)

These two parameters serve different purposes:

Parameter Purpose Behavior
ms_delay Add extra wait time Waits for the specified time after the page loads
max_wait_ms Set a time limit Stops waiting before the specified time, even if content is still loading
  • Use ms_delay when you need to wait for JavaScript to execute or animations to complete
  • Use max_wait_ms when pages load too much content and you want to capture sooner

If a page loads unnecessary content that slows down your screenshot:

{
"url": "https://heavy-website.com",
"max_wait_ms": 2000
}

You can use both parameters together. The API will wait for ms_delay but not exceed max_wait_ms:

{
"url": "https://example.com",
"ms_delay": 1000,
"max_wait_ms": 3000
}

For simple pages where you want quick renders:

{
"html": "<div>Simple content</div>",
"max_wait_ms": 500
}

Many news sites load ads and tracking scripts that delay screenshots:

{
"url": "https://news-site.com/article",
"max_wait_ms": 3000,
"block_consent_banners": true
}

Product pages often have heavy JavaScript. Limit wait time to get faster screenshots:

{
"url": "https://shop.example.com/product/123",
"max_wait_ms": 4000,
"selector": ".product-image"
}

When generating many screenshots, use max_wait_ms to prevent slow pages from blocking your queue:

{
"url": "https://example.com",
"max_wait_ms": 5000
}
  1. Start with the default - Only use max_wait_ms if screenshots are taking too long
  2. Test your value - Too short a time may result in incomplete screenshots
  3. Combine with selector - Use selector to capture specific elements that load quickly
  4. Consider render_when_ready - For precise control, use render_when_ready instead

Need help?

Talk to a human. Email support@htmlcsstoimage.com and we’ll help you get started.