Skip to main content
Many modern websites load content dynamically with JavaScript. Screenshotly provides two mechanisms to ensure content is fully rendered before capturing.

Delay parameter

The delay parameter specifies how many milliseconds to wait after the page loads before taking the screenshot:
const screenshot = await client.capture({
  url: 'https://example.com',
  delay: 3000 // wait 3 seconds
});
Use delay when:
  • The page has animations that need to complete
  • Content loads via JavaScript after the initial page load
  • You need to wait for fonts or images to render

Wait for selector

The waitForSelector parameter waits for a specific DOM element to appear before capturing:
const screenshot = await client.capture({
  url: 'https://example.com/dashboard',
  waitForSelector: '.dashboard-loaded'
});
This is more reliable than a fixed delay because it captures as soon as the element exists, rather than waiting an arbitrary amount of time. Use waitForSelector when:
  • A specific element indicates the page is ready (e.g., a data table, chart, or content container)
  • Content loads asynchronously and you need to wait for it
  • Single-page applications (SPAs) render content after JavaScript hydration

Combining both

You can use delay and waitForSelector together. The API waits for the selector first, then applies the additional delay:
const screenshot = await client.capture({
  url: 'https://example.com/charts',
  waitForSelector: '.chart-container',
  delay: 1000 // extra second after element appears
});
When capturing SPAs built with React, Vue, or Angular, use waitForSelector targeting a container that only renders after data loads. This is more reliable than guessing a delay value.

Timeout

If the page takes too long to load or the selector never appears, the request will time out. The default timeout is 30 seconds. You can customize it with the timeout parameter:
const screenshot = await client.capture({
  url: 'https://slow-site.example.com',
  waitForSelector: '.content',
  timeout: 60000 // 60 seconds
});
If the waitForSelector element never appears on the page, the request will fail after the timeout period. Make sure the selector matches an element that will exist on the target page.