Glossary
JavaScript rendering: letting the page build itself
JavaScript rendering means running a page's scripts, usually in a headless browser, so that content built on the client side appears before you read the page.
Definition
Modern sites often send a light HTML shell and let JavaScript build the visible page. The browser downloads scripts, calls APIs, and inserts the results into the DOM. An HTTP client that only downloads the HTML never runs those scripts, so it sees the shell without the content. Rendering closes that gap by executing the scripts the way a browser would.
Rendering models you will meet
- Server side rendering (SSR): the server sends complete HTML. No rendering needed on your side.
- Client side rendering (CSR): the server sends a shell and scripts build everything. Rendering, or the underlying API, is needed.
- Hydration: complete HTML arrives, then scripts attach behavior. Data is usually in the HTML and often in an embedded JSON state blob too.
- Partial loading: the main content is static but prices, stock or reviews load afterwards. You may need rendering for those parts only.
When you need a browser
Use this order of checks before reaching for a headless browser, because rendering costs far more CPU, memory and time per page:
- Is the value in the raw HTML? Then parse it directly.
- Is it in an embedded JSON blob, such as a framework state script? Then extract that JSON.
- Does the page fetch it from a JSON endpoint you can call yourself? Then use that endpoint. See hidden API scraping.
- Does the data depend on interaction, signed request parameters computed in the page, or bot checks that require a real browser? Then render.
The last case is common on sites protected by advanced bot management, which require scripts to run before any content is served.
Rendering tools
Playwright, Puppeteer and Selenium drive real browser engines. Frameworks such as Scrapy can delegate selected requests to a browser through plugins. Key settings are what you wait for (a selector, a network idle state, a specific response) and what you block (images, fonts, media) to save time and bandwidth.
from playwright.sync_api import sync_playwright
with sync_playwright() as pw:
browser = pw.chromium.launch()
page = browser.new_page()
page.route("**/*.{png,jpg,jpeg,woff2,mp4}", lambda r: r.abort())
page.goto("https://example.com/listings", wait_until="domcontentloaded")
page.wait_for_selector("div.listing-card")
html = page.content()
browser.close()
Rendering and bot checks
A headless browser passes the "can you run JavaScript" test that plain clients fail, but it adds its own signals, covered under headless browser detection. Expect challenges anyway on strict sites. Inside a rendered session, solving fits naturally: read the site key from the DOM, send a reCAPTCHA v2 or Cloudflare Turnstile task, and inject the token into the page before submitting. Typical token tasks complete under 3 seconds, so the page rarely times out while you wait.
Common questions
How do I know if a page needs JavaScript rendering?
Fetch it with a plain HTTP client and search for a value you see on screen. If it is missing, the content is built by scripts.
Is rendering always slower?
Yes, by a wide margin. A browser loads scripts and assets and uses far more memory than an HTTP request.
Can I avoid rendering on client side rendered sites?
Often. The data usually comes from a JSON endpoint or an embedded state object that you can read directly.
What should I wait for after loading a page?
Wait for the element or network response that carries your data, rather than a fixed sleep or a generic load event.
Does rendering stop CAPTCHAs from appearing?
No. It passes basic script checks, but bot defenses still score the browser and may show a challenge.
Keep reading
- Dynamic scrapingDynamic scraping collects data loaded by scripts or background XHR calls, either by driving a browser or calling those endpoints directly.
- Headless browserA real browser engine running without a visible window, driven by code for tests, screenshots and pages that need JavaScript.
- DOMThe DOM is the live element tree that scripts keep changing, so it often differs from the HTML the server sent.
- How do I scrape JavaScript-heavy sites efficiently?Find the JSON a page loads or embeds before rendering anything, and when you must render, keep the browser lean.