Guides / Performance

Performance and blocking

Modern pages ship megabytes of JavaScript and third-party tags. You can wait for the exact DOM state you care about, strip entire resource classes, and apply opinionated content filters so captures finish faster and look cleaner.

Overview

Tuning is iterative: start with defaults, measure X-ScreenNabster-Duration from sync responses, then introduce wait_until, wait, and blocking options until variance drops. Always validate visually—blocking scripts can break SPAs entirely.

Cache repeated captures

Set cache=true (or cached=true) when repeated requests should reuse a stored render. Cache hits return X-ScreenNabster-Cache: HIT, include X-ScreenNabster-Cache-Url when available, and do not consume monthly quota. Use cache_key to separate variants and cache_ttl to control signed URL lifetime. Fresh JSON responses include cache_url after a successful cache write; JSON cache hits return the cached image bytes with empty metadata because page metadata is not stored in the cache object.

curl
curl -G "https://screennabster.com/api/v1/capture" \
  --data-urlencode "url=https://example.com" \
  --data-urlencode "cache=true" \
  --data-urlencode "cache_ttl=14400" \
  -H "X-API-Key: pk_live_…" \
  --output cached.png

Waits & readiness

wait_until picks the navigation milestone. networkidle is stricter than load and helps SPAs settle. Add wait (milliseconds) for fixed delays such as carousel animations, or wait_for_selector when a known selector marks readiness.

body.json
{
  "url": "https://example.com/app",
  "wait_until": "networkidle",
  "wait_for_selector": "[data-ready=true]",
  "wait": 250,
  "output": "png"
}

Block resource types

block_resources accepts Playwright types: image, stylesheet, font, media, script, xhr, fetch. Blocking images speeds up text-heavy captures; blocking scripts may blank React apps—test carefully.

curl
curl -G "https://screennabster.com/api/v1/capture" \
  --data-urlencode "url=https://example.com" \
  --data-urlencode "block_resources=image,media" \
  -H "X-API-Key: pk_live_…" \
  --output lite.png

Content filters

filters enables higher-level bundles: cookie_banners, ads, popups, chats, trackers. They complement—not replace—your own hide_selectors lists for brand-specific overlays.

Strip ads

strip_ads: true flips on host-based blocking tuned for common ad networks. Pair with filters when pages still leak sponsored modules through first-party domains.

Tradeoffs

  • Aggressive blocking can break A/B tests that rely on client-side scripts.
  • For captures that still exceed your HTTP timeout, switch to background mode.
  • Keep an eye on quota—every attempt counts once admitted past the gate.