A screenshot taken too early shows a spinner, a fallback font or a half-faded card. One taken with the wrong wait condition can take 20 seconds or time out. We built a test page that loads in stages, captured it once for each of Puppeteer's wait conditions, and recorded what each image actually showed.
The short version: load, networkidle2 and a fixed one-second sleep all captured "Loading products…" instead of the products. networkidle0 captured the finished page, but took 20.8 seconds because a chat-style long poll held a connection open. With the poll held open for 60 seconds it failed with a TimeoutError. waitForSelector alone fired while the product images were still missing and the cards were mid-fade. What worked was waiting for the content itself and then for its images, fonts and animations. The helper that does this is below, with the edge cases we tested it on.
What each wait condition means
page.goto() resolves when the condition in waitUntil is met. Puppeteer's documentation defines four:
| Condition | Resolves when |
|---|
domcontentloaded | The DOMContentLoaded event fires: the HTML is parsed and deferred scripts have run. It doesn't wait for images, subframes or async scripts. |
load (the default) | The load event fires: stylesheets, scripts, iframes and images have loaded, except lazily loaded ones. |
networkidle2 | There have been no more than 2 network connections for at least 500 ms. |
networkidle0 | There have been no network connections for at least 500 ms. |
The default timeout is 30,000 ms, and waitUntil also accepts an array, in which case all the listed events must fire. None of these conditions knows anything about your page. A request fired by JavaScript after the load event isn't covered by load, and two slow requests are invisible to networkidle2.
The test page
We wrote a small Node server that delays each part of a shop page by a set amount, so every run loads the same way:
| Part | Arrives after |
|---|
| HTML, with a "Loading products…" placeholder | at once |
| Stylesheet | 300 ms |
| Hero image ("Autumn sale") | 400 ms |
Web font for the headings (JetBrains Mono, font-display: swap) | 600 ms |
| Products API, fetched by a script once the HTML arrives | 2,000 ms |
| Six product images, added when the API answers | 900 ms each |
| A long poll, like a chat widget's | held open for 20 s |
The product cards fade in over 800 ms. A small "Chat" badge pulses for ever. Each capture used a new browser context and a 1000 × 560 viewport, and we timed from just before page.goto() to the end of the wait.
What each condition captured
We ran every strategy three times. All three runs of each strategy captured the same state, and the timings varied by less than 30 ms.
| Strategy | Time (median) | Product cards | Images loaded | Web font | Result |
|---|
domcontentloaded | 0.33 s | 0 | 0 of 1 | no | Placeholder, fallback font, no hero |
load | 0.93 s | 0 | 1 of 1 | yes | Placeholder |
load + 1 s sleep | 1.93 s | 0 | 1 of 1 | yes | Placeholder |
networkidle2 | 1.45 s | 0 | 1 of 1 | yes | Placeholder |
networkidle0 | 20.83 s | 6 | 7 of 7 | yes | Complete, 19 s late |
waitForSelector('.card') | 2.32 s | 6 | 1 of 7 | yes | Cards invisible, no images |
waitForPageReady('.card') | 4.14 s | 6 | 7 of 7 | yes | Complete |

load caught the font, not the products. We also checked whether the load event waits for a web font. On this page it did: in a separate probe, the navigation's loadEventStart was 927 ms and the font finished at 926 ms. When we slowed the font to 2.5 seconds, the load event moved to about 4.1 seconds. By then the products had arrived and their images were loading, so load produced a complete screenshot by accident. A faster font would have broken it. Whether load happens to cover content fetched by JavaScript depends on a race you don't control.
A fixed sleep is a guess. One extra second after load still showed the placeholder. A longer sleep would have worked here and failed on a slower day.
networkidle2 is fooled by two slow requests. From about 0.9 seconds on, only the products API call and the long poll were open. That is two connections, which networkidle2 allows, so it resolved 500 ms later with the placeholder still on screen.
networkidle0 waited for the chat widget. It waited until the long poll closed at 20 seconds, then 500 ms more. When we held the poll open for 60 seconds, goto failed with TimeoutError: Navigation timeout of 30000 ms exceeded after 30,003 ms. Any page with an open WebSocket, server-sent events or a long poll can do this. One more thing we hit while building the test: in an early version the page never read the long poll's response body. Puppeteer then never saw that request finish. In a check with a 40-second timeout, networkidle0 timed out, although our server's log shows it closed the response after 20 seconds. Reading the body, as real long-poll code does, fixed it.

waitForSelector fires too early for a screenshot. It returns as soon as the element is in the DOM. At that moment, 1 of 7 images had loaded and the first card's computed opacity was 0, at the very start of its fade-in. The visible: true option doesn't help here: Puppeteer's documentation defines visible as not display: none and not visibility: hidden, and a card at opacity 0 is neither.
A helper that waits for the page to be ready
The strategy that worked waits for the content you want, then for the three things that still change how it looks: images, fonts and animations.
async function waitForPageReady(page, selector, { timeout = 30000 } = {}) {
await page.waitForSelector(selector, { visible: true, timeout });
await page.waitForFunction(
() =>
[...document.images].every(
(img) =>
img.complete ||
(img.loading === "lazy" && img.getBoundingClientRect().top >= window.innerHeight),
),
{ timeout },
);
await page.evaluate(() => document.fonts.ready.then(() => true));
await page.evaluate(() =>
Promise.all(
document
.getAnimations()
.filter((a) => a.effect?.getComputedTiming().endTime !== Infinity)
.map((a) => a.finished),
).then(() => true),
);
}
module.exports = { waitForPageReady };
Use it after a quick navigation:
const puppeteer = require("puppeteer");
const { waitForPageReady } = require("./ready");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1000, height: 560 });
await page.goto("http://localhost:8737/", { waitUntil: "domcontentloaded" });
await waitForPageReady(page, ".card");
await page.screenshot({ path: "shop.png" });
await browser.close();
})();
What each step relies on:
- The selector should name something that only exists once the data has arrived: a product card, a table row or a chart's SVG. A container that exists in the initial HTML doesn't tell you anything.
img.complete is true once an image has been fully fetched, and also when it failed to load, so a broken image won't hang the wait. It is false for a loading="lazy" image that hasn't started. We checked that in Chrome 156: an off-screen lazy image reported complete = false until we scrolled it into view, then true. Without the lazy-image exception, the helper would time out on any page with lazy images below the fold. With it, the helper finished in 3.8 seconds on our test page with such an image added. For full-page captures, scroll the page first so those images load; our guide to blank images in full-page screenshots covers that.
document.fonts.ready resolves once the document has finished loading fonts, layout is done, and no further font loads are needed.
document.getAnimations() returns CSS animations, CSS transitions and Web Animations. Waiting on every finished promise without the filter never ends if anything loops: on our page the pulsing badge kept that promise pending until we gave up after 10 seconds. An animation that repeats for ever has an end time of Infinity, which is what the filter skips.
How long networkidle costs on real sites
On our test page networkidle0 took 20 seconds. Most sites don't hold connections open like that, so we timed the four waitUntil conditions on five real pages, each in a fresh browser context, twice. These are separate navigations, so in some runs domcontentloaded came in later than load from another run.
| Page | domcontentloaded | load | networkidle2 | networkidle0 |
|---|
| github.com | 303–415 ms | 346–357 ms | 1,230–1,262 ms | 1,535–1,631 ms |
| developer.mozilla.org/en-US/ | 69–82 ms | 103–120 ms | 997–999 ms | 1,100–1,430 ms |
| react.dev | 159–258 ms | 200–252 ms | 757–902 ms | 881–962 ms |
| bbc.com/news | 174–212 ms | 202–211 ms | 1,261–1,346 ms | 1,417–1,456 ms |
| theguardian.com/uk | 87–104 ms | 227–238 ms | 889–997 ms | 998–1,000 ms |
None of the ten networkidle0 navigations timed out, and each took about 0.6 to 1.3 seconds longer than load. Part of that is built in: both network-idle conditions need 500 ms of quiet before they resolve. On ordinary pages networkidle0 is a cheap safety margin. It still can't tell you that the content you care about is on screen, and on a page with a socket that never closes it never resolves.
Choosing a wait condition
- For your own app or a page you know: use
domcontentloaded, then wait for a selector that proves the data is there, then for images, fonts and animations, as the helper does. It was the only strategy that was both complete and fast on our test page.
- For arbitrary URLs, where you can't name a selector:
networkidle0 with an explicit timeout, and a fallback that still takes the screenshot if the timeout fires, is a reasonable default. Expect pages with chat widgets or live feeds to hit that timeout.
- Avoid fixed sleeps. They are always either too long or too short.
If you capture through an API instead of running Chrome yourself, look for the same two settings. Our screenshot API takes waitUntil with the four values above, and waitFor, a selector to wait for before capturing.
How we tested
The server, the test page, the capture script, the probes and the logs are all ours, written for this article. Everything ran on 25 October 2026 with Puppeteer 25.16.0, the latest release on npm that day, and the Chrome for Testing build it downloads, 156.0.8078.47. The server ran on the same machine as the browser, so the delays are the server's own and not network noise. The real-site timings were taken from the same machine the same morning. Treat them as a comparison between conditions rather than as the sites' general speed.