I ran 300 pages through four different scrapers on the same machine, and the result decides most "Playwright vs HTTP requests for web scraping" arguments before they start. Reading a page's JSON endpoint ran at about 430 pages per second on 144 MB of memory. Loading the same page in a headless Chromium via Playwright ran at 15 to 17 pages per second and needed roughly a gigabyte.
That is a 25x to 30x gap in throughput and a 6x to 7x gap in memory for identical data. If you are scoping a scraper, that gap is your hosting bill, your run time and a big part of your maintenance risk. This article shows the numbers, where the benchmark misleads, and the rule I use to decide which approach a web scraping and data extraction project needs.
What I measured, and what the test cannot tell you#
The setup is deliberately simple so you can repeat it. A small Node server on localhost serves 300 "product listing" pages with 20 records each (6,000 records in total). Every request has a fixed 20 ms of simulated server latency. There are two page styles:
- Server-rendered HTML: the records are in the markup. Nothing else to load.
- Single-page style: a small HTML shell, a 470 KB JavaScript bundle, a CSS file and six 180 KB images, with the records fetched from
/api/productsafter the page loads and written into the DOM.
I ran four strategies, three times each, on a 4-core, 16 GB machine. The figures below are the median run, and the three runs were within 3% of each other.
| Strategy | Time for 300 pages | Pages per second | Peak memory |
|---|---|---|---|
| Call the JSON endpoint directly (10 concurrent) | 0.7 s | about 430 | 144 MB |
| Fetch server-rendered HTML and parse (10 concurrent) | 0.7 s | about 450 | 147 MB |
| Playwright, new browser context per page, all assets loaded (4 concurrent) | 19.3 s | 15.5 | about 930 MB |
| Playwright, one shared context, images, CSS and fonts blocked (4 concurrent) | 17.6 s | 17.1 | about 1,000 MB |
Memory includes the Node process itself, so the browser's share is roughly 800 MB to 850 MB at four parallel pages.
Be careful with these numbers. This is a localhost benchmark with no real network, no anti-bot layer and no slow third-party scripts. A real site that answers in 600 ms and ships 4 MB of assets will slow both approaches, and the browser will suffer more, because it downloads and executes everything. Treat the ratios as the lesson, not the absolute figures.
One result surprised me. Blocking images, CSS and fonts barely helped here, about 9% faster. With assets served from localhost there was almost no transfer time to save. On a real connection that blocking matters much more, and I would still do it for the bandwidth alone.
Why the browser is so much more expensive#
Fetching JSON costs one request and one parse. A browser page costs a lot more, and none of it is waste from the browser's point of view:
- It starts or reuses a renderer process and allocates a page.
- It downloads the HTML, then the scripts, styles and images the HTML references.
- It parses and executes the JavaScript bundle, builds the DOM and lays the page out.
- It runs the page's own API calls, and only then does the data you wanted appear.
Your scraper wanted step 4 only. Steps 1 to 3 are the price of getting there through the front door.
Concurrency makes the memory cost obvious. I re-ran the blocked-assets strategy at different parallelism on the same machine:
| Parallel pages | Pages per second | Peak memory |
|---|---|---|
| 1 | 6.0 | 575 MB |
| 2 | 11.4 | 711 MB |
| 4 | 17.2 | 927 MB |
| 8 | 20.7 | 1,381 MB |
Going from 4 to 8 parallel pages bought 20% more throughput for 50% more memory. On a 4-core box the CPU becomes the limit before memory does, so there is a sensible ceiling around the number of cores, and pushing past it mostly increases failures and timeouts.
Look for the JSON endpoint before you open a browser#
Most "JavaScript-heavy" sites are not hard to scrape. They are just pages whose data arrives from an internal JSON endpoint, exactly like my single-page test above. Open the browser's Network tab, filter by Fetch/XHR, reload the page and look for the request that returns your records. If it exists, you can often call it directly.
A direct call in Laravel is a few lines. This uses the HTTP client's request pool to fetch ten pages at once:
use Illuminate\Http\Client\Pool;
use Illuminate\Support\Facades\Http;
$responses = Http::pool(fn (Pool $pool) => collect(range(1, 10))
->map(fn (int $page) => $pool->as("page-{$page}")
->acceptJson()
->timeout(15)
->retry(2, 500)
->get('https://example.com/api/products', ['page' => $page]))
->all());
foreach ($responses as $key => $response) {
if ($response->failed()) {
report(new \RuntimeException("{$key} failed: {$response->status()}"));
continue;
}
// $response->json() is already structured data. No selectors to maintain.
}The bigger benefit is not speed, it is maintenance. A CSS selector breaks when someone redesigns a button. A JSON field named price rarely changes name, and when it does, your tests fail loudly instead of silently returning empty rows. That ties directly into how I keep scraped data trustworthy, because structured fields make hashing and field-level diffs far simpler.
Advertisement
Two warnings before you lean on a hidden endpoint. First, it is undocumented, so it can change without notice. Second, it may need a token, cookie or signed header that the page generates in JavaScript. If reproducing that takes more effort than running a browser, the browser may well be the cheaper option. And if an official API gives you the same data, use it. I compared that decision in detail in web scraping vs an official API.
When the browser really is the right tool#
I use a headless browser when one of these is true:
- There is no endpoint to call. The data is assembled in the page from several sources, or is only produced by running a script.
- The request is protected by logic you cannot reasonably copy. Think signed parameters, rotating tokens or challenge flows that are produced client-side.
- You need to behave like a logged-in user. A multi-step flow with clicks, uploads or downloads where the site tracks state in the page.
- The volume is small and the value per page is high. A few hundred pages a day does not justify reverse-engineering anything.
My clearest example is Zinzap, the privacy-first WhatsApp desktop client. WhatsApp has no public API for personal accounts, so the app builds on whatsapp-web.js, which drives WhatsApp Web through a headless Chromium inside an Electron app. There was no endpoint to call and no realistic way to copy the client's logic, so a real browser was the only route. I accepted the cost, because one user on one machine does not care about 800 MB, and I treated the dependency as fragile and kept everything else local.
Compare that with the EXPRECO logistics quote system, which needed live shipping rates. UPS and FedEx both offer APIs, so the rates come from the UPS and FedEx APIs and not from any page. Calling an API there cost almost nothing to run, and a browser would have been slower, more fragile and harder to justify to a client.
Making the browser cheaper when you must use it#
If you do need Playwright, a few choices change the bill a lot. The first is to stop launching a browser per page. Launch one browser, reuse a context and open a fresh page for each job. Contexts are cheap isolated sessions, as the Playwright docs describe, while a launched browser is the expensive part.
The second is to block what you do not read. Playwright can intercept requests per context, which the network documentation covers:
const { chromium } = require('playwright');
const browser = await chromium.launch();
const context = await browser.newContext();
await context.route('**/*', (route) => {
const type = route.request().resourceType();
return ['image', 'stylesheet', 'font', 'media'].includes(type)
? route.abort()
: route.continue();
});
async function scrape(url) {
const page = await context.newPage();
try {
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.waitForSelector('li.p'); // wait for the data, not for the page
return await page.$$eval('li.p', (rows) =>
rows.map((r) => ({ id: r.dataset.id, name: r.querySelector('b').textContent }))
);
} finally {
await page.close();
}
}The third is to wait for the data, not for the page. waitUntil: 'load' waits for every image and script; domcontentloaded plus a wait for the element you actually need is faster and more honest about what you depend on.
The fourth is to cap concurrency to your core count and recycle the browser periodically. Memory tends to creep up in long runs, so restart the browser every few hundred pages and queue the work so a crash retries the batch instead of losing it.
A small piece of advice from the benchmark itself: my first version of the test reported 3,900 records instead of 6,000, and the cause was a JavaScript trap, not the scraper. I had written total += await page.count() inside concurrent workers. The total is read before the await completes, so parallel workers overwrote each other's sums. Assign the awaited value to a variable first, then add it. The scrape was fine; the counting was wrong, and nothing crashed. It is the same family of bug I describe in the Laravel double-accept race condition.
What this does to the budget#
Here is the same difference expressed for a job of 100,000 pages, using the localhost figures above:
| Approach | Time at measured speed | Memory you must provision |
|---|---|---|
| JSON endpoint or HTML fetch | about 4 minutes | well under 1 GB |
| Playwright, 4 parallel pages | about 1 hour 37 minutes | about 1 GB, more with real-world pages |
On real sites, with real latency and heavier pages, expect both numbers to grow, and the browser's to grow faster. This is why I ask three questions before quoting a scraper, and they are the same ones behind what a custom web scraper costs:
- Is there an API or JSON endpoint? If yes, the build is smaller and the monthly cost is closer to zero.
- How many pages per day, and how fresh must they be? A daily run of 5,000 pages tolerates a browser. An hourly run of 500,000 does not.
- Who is on the other end? Respect the target's rules. The Robots Exclusion Protocol is RFC 9309, and the legal side deserves its own check, which I cover in whether web scraping is legal for a business.
A decision rule I actually use#
- Check for an official API. Use it if it covers your data and terms allow it.
- Check the Network tab for a JSON endpoint. If you find one that works without tricky tokens, call it directly.
- Check whether the HTML already contains the data. Plain HTTP and a parser is the cheapest scraper you can run.
- Only then reach for Playwright, and set it up with one browser, shared contexts, blocked assets and a concurrency cap.
- Isolate the browser step so the rest of your pipeline does not care how a page was fetched. That is the core idea in building a resilient data collection system: when the source changes, you swap one adapter, not the system.
Frequently asked questions#
Is Playwright slower than requests for web scraping?#
Yes. In my test, direct HTTP calls ran about 25x to 30x faster than Playwright and used about one sixth of the memory. The browser is justified only when the data cannot be reached without running the page.
Can Playwright be as fast as a direct API call?#
Not for the same data. You can narrow the gap by reusing contexts, blocking assets and waiting for the data element, which in my test gave about a 9% improvement on localhost and more on a real network. It will still be an order of magnitude slower.
How many parallel Playwright pages should I run?#
Start at your CPU core count. On my 4-core machine, going from 4 to 8 pages added 20% throughput and 50% more memory. Measure on your own hardware, because page weight changes the answer.
How do I find the hidden JSON endpoint of a website?#
Open the browser developer tools, go to the Network tab, filter by Fetch/XHR, reload and look for a response containing your data. Check its request headers for tokens before you build on it.
What I would tell a client#
- Do not default to a browser. Spend an hour looking for an API, a JSON endpoint or data in the HTML first.
- A headless browser costs roughly 25x to 30x the time and 6x to 7x the memory in my test, so it should be the exception that you can justify.
- When a browser is unavoidable, reuse one browser, block assets, wait for the data and cap concurrency.
- Keep the fetching layer isolated, so a change on the target site is a small fix.
If you are weighing a scraper and want a straight answer on which route fits your data, book a call and I will tell you what I would check first.
Share this technical insight with your network
Share to LinkedIn or Facebook with key takeaways, featured media, and direct links.

About the author
Aqib Javaid
Senior Full-Stack Engineer
8+ years building Laravel, React/Next.js and AI-powered products for startups and growing businesses - SaaS platforms, APIs, integrations and the performance work that keeps them fast. Read the case studies to see how that plays out on real projects.
4.9 from 76 client reviews
Case Study: Zinzap: Privacy-First WhatsApp Desktop Client
Zinzap is a desktop WhatsApp client built for people who read chats in public places or share their screen. I built an Electron app with fake names, blurred media, layered locks and a built-in calendar, tasks and media gallery.
Related Technical Articles
View all articles →Web Scraping vs Official API: Which Should You Use?
Before you commission a scraper, check whether an API gives you the same data. Here is how to compare reliability, cost, legality and maintenance, and when scraping is still the right call.
How Much Does a Custom Web Scraper Cost to Build?
What a custom web scraper costs depends on the target sites, the volume, the anti-bot defences and how reliable it has to be. Here is how to scope it and what to budget for upkeep.

Scraped Data Change Detection: From Snapshots to Reliable Alerts
How I design change detection for scraped data: stable record identity, normalisation, content hashing, field-level diffs and alerts users trust, with Laravel and MySQL examples.

How to Build a Resilient Web Data Collection System
General principles for building web data collection systems that keep working as external sources change: isolation, normalization, failure handling and monitoring.
Have a complex technical project in mind?
Available for full-stack engineering, performance audits, cloud deployments, and high-concurrency systems architecture.

