Puppeteer can stop a page request before it downloads, let it continue unchanged, or replace it with your own response. Enable interception with await page.setRequestInterception(true), then resolve every intercepted request with request.abort(), request.continue(), or request.respond(). The important constraint is that interception stalls requests until one of those outcomes is chosen (or the browser serves the request from cache).
This guide shows a safe blocking pattern, ad and tracker rule design, multi-handler coordination, experimental URL blocklists, troubleshooting, and an API alternative when you do not want to maintain a browser worker.
Enable interception before navigation
Turn interception on before opening the target URL so the initial document and its subresources pass through your handler.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', request => {
return request.continue();
});
await page.goto('https://example.com', {waitUntil: 'networkidle2'});
await page.screenshot({path: 'page.png', fullPage: true});
await browser.close();
})();
Every request event must reach a terminal decision. If a handler neither continues, aborts, nor responds, page activity can hang indefinitely. Register the handler before goto, and keep the default path explicit even when you are only blocking a few hosts.
Recommended Free Tools
#1 Best Overall
- DUAL-BAND WIFI 6 ROUTER: Wi-Fi 6(802.11ax) technology achieves faster speeds, greater capacity and reduced network congestion compared to the previous gen. All WiFi routers require a separate modem. Dual-Band WiFi routers do not support the 6 GHz band.
- AX1800: Enjoy smoother and more stable streaming, gaming, downloading with 1.8 Gbps total bandwidth (up to 1200 Mbps on 5 GHz and up to 574 Mbps on 2.4 GHz). Performance varies by conditions, distance to devices, and obstacles such as walls.
- CONNECT MORE DEVICES: Wi-Fi 6 technology communicates more data to more devices simultaneously using revolutionary OFDMA technology
- EXTENSIVE COVERAGE: Achieve the strong, reliable WiFi coverage with Archer AX1800 as it focuses signal strength to your devices far away using Beamforming technology, 4 high-gain antennas and an advanced front-end module (FEM) chipset
- OUR CYBERSECURITY COMMITMENT: TP-Link is a signatory of the U.S. Cybersecurity and Infrastructure Security Agency’s (CISA) Secure-by-Design pledge. This device is designed, built, and maintained, with advanced security as a core requirement.
Block a host, URL, or resource type
Block by hostname or URL fragment
A rule can inspect request.url() and abort matching traffic. The hostname test below is illustrative; replace it with domains you have verified for your own target sites. Puppeteer does not publish a canonical ad or tracker taxonomy.
const blockedHosts = new Set([
'example-tracker-domain.test',
'ads.example.test'
]);
await page.setRequestInterception(true);
page.on('request', request => {
const url = new URL(request.url());
if (blockedHosts.has(url.hostname)) {
return request.abort();
}
return request.continue();
});
Use an exact hostname set when you know the infrastructure. For controlled test environments, a suffix rule can cover subdomains:
const blockedSuffixes = ['.doubleclick.example', '.telemetry.example'];
page.on('request', request => {
const hostname = new URL(request.url()).hostname;
const shouldBlock = blockedSuffixes.some(suffix => hostname.endsWith(suffix));
return shouldBlock ? request.abort() : request.continue();
});
Do not use a broad substring such as ads without checking false positives. A legitimate application endpoint can contain the same text.
Block images, fonts, or other resource classes
The request object exposes the resource type. This is useful for reducing bandwidth, but it can break layouts or functionality when images, fonts, stylesheets, or scripts are required.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
const blockedTypes = new Set(['image', 'media']);
page.on('request', request => {
if (blockedTypes.has(request.resourceType())) {
return request.abort();
}
return request.continue();
});
A safer production policy is usually host plus type: block third-party media from known hosts while allowing first-party assets.
Return a synthetic response
request.respond() fulfills a request without contacting its origin. This is useful for deterministic tests.
page.on('request', request => {
if (request.url().endsWith('/feature-flags.json')) {
return request.respond({
status: 200,
contentType: 'application/json',
body: JSON.stringify({newCheckout: false})
});
}
return request.continue();
});
Only provide response fields your test needs. A malformed body or mismatched content type can produce application errors that look like page failures.
Build rules that do not break the page
Start with observation
Before aborting anything, log requests and classify them by hostname, resource type, and whether they are first- or third-party. Capture a representative set of routes, including login, checkout, consent, and error pages. Then block one rule at a time and verify the resulting DOM and network behavior.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →page.on('request', request => {
const url = new URL(request.url());
console.log(request.resourceType(), url.hostname, url.pathname);
return request.continue();
});
Keep rules in configuration rather than scattering string tests through handlers. Record why each domain is blocked and an owner or review date so stale vendor domains can be removed.
Rank #2
- 𝐅𝐮𝐭𝐮𝐫𝐞-𝐑𝐞𝐚𝐝𝐲 𝐖𝐢-𝐅𝐢 𝟕 - Designed with the latest Wi-Fi 7 technology, featuring Multi-Link Operation (MLO), Multi-RUs, and 4K-QAM. Achieve optimized performance on latest WiFi 7 laptops and devices, like the iPhone 16 Pro, and Samsung Galaxy S24 Ultra.
- 𝟔-𝐒𝐭𝐫𝐞𝐚𝐦, 𝐃𝐮𝐚𝐥-𝐁𝐚𝐧𝐝 𝐖𝐢-𝐅𝐢 𝐰𝐢𝐭𝐡 𝟔.𝟓 𝐆𝐛𝐩𝐬 𝐓𝐨𝐭𝐚𝐥 𝐁𝐚𝐧𝐝𝐰𝐢𝐝𝐭𝐡 - Achieve full speeds of up to 5764 Mbps on the 5GHz band and 688 Mbps on the 2.4 GHz band with 6 streams. Enjoy seamless 4K/8K streaming, AR/VR gaming, and incredibly fast downloads/uploads.
- 𝐖𝐢𝐝𝐞 𝐂𝐨𝐯𝐞𝐫𝐚𝐠𝐞 𝐰𝐢𝐭𝐡 𝐒𝐭𝐫𝐨𝐧𝐠 𝐂𝐨𝐧𝐧𝐞𝐜𝐭𝐢𝐨𝐧 - Get up to 2,400 sq. ft. max coverage for up to 90 devices at a time. 6x high performance antennas and Beamforming technology, ensures reliable connections for remote workers, gamers, students, and more.
- 𝐔𝐥𝐭𝐫𝐚-𝐅𝐚𝐬𝐭 𝟐.𝟓 𝐆𝐛𝐩𝐬 𝐖𝐢𝐫𝐞𝐝 𝐏𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞 - 1x 2.5 Gbps WAN/LAN port, 1x 2.5 Gbps LAN port and 3x 1 Gbps LAN ports offer high-speed data transmissions.³ Integrate with a multi-gig modem for gigplus internet.
- 𝐎𝐮𝐫 𝐂𝐲𝐛𝐞𝐫𝐬𝐞𝐜𝐮𝐫𝐢𝐭𝐲 𝐂𝐨𝐦𝐦𝐢𝐭𝐦𝐞𝐧𝐭 - TP-Link is a signatory of the U.S. Cybersecurity and Infrastructure Security Agency’s (CISA) Secure-by-Design pledge. This device is designed, built, and maintained, with advanced security as a core requirement.
Choose abort errors deliberately
request.abort() can take an error code. The default is generally sufficient for ad and tracker suppression. If your application distinguishes offline, refused, or blocked traffic, choose the code deliberately and test how the page handles it.
Remember service workers and cached responses
Interception applies to requests surfaced through Puppeteer, but a page can satisfy work from service-worker or browser caches. The interception documentation notes that requests can complete from browser cache; do not assume every resource generates a fresh network decision. For reproducible tests, use a clean context and control service-worker state where appropriate.
Coordinate multiple request handlers
Libraries and application code can both register request listeners. Two listeners may attempt to resolve the same request. Before resolving, check request.isInterceptResolutionHandled(). If you await asynchronous work, check again immediately after the await; another handler may have won while your code was paused.
page.on('request', async request => {
if (request.isInterceptResolutionHandled()) return;
const blocked = request.url().includes('example-tracker-domain.test');
if (blocked) {
if (request.isInterceptResolutionHandled()) return;
return request.abort();
}
if (request.isInterceptResolutionHandled()) return;
return request.continue();
});
The check and the resolution call should be adjacent and synchronous. A check performed much earlier is not a lock.
Use cooperative priorities only when all handlers support them
Puppeteer’s Cooperative Intercept Mode lets handlers provide a numeric priority to abort, continue, or respond. Puppeteer waits for handlers, then selects the highest-priority decision. If priorities tie, the documented order is abort, respond, then continue.
const {DEFAULT_INTERCEPT_RESOLUTION_PRIORITY} = puppeteer;
page.on('request', request => {
if (request.isInterceptResolutionHandled()) return;
if (request.url().includes('example-tracker-domain.test')) {
return request.abort('blockedbyclient', 10);
}
return request.continue({}, DEFAULT_INTERCEPT_RESOLUTION_PRIORITY);
});
A handler that omits a priority uses legacy immediate resolution and changes the coordination model. Do not add priorities casually; first inspect every listener installed by your application and its dependencies. A default continuation at priority zero can leave room for a higher-priority decision, but only in a consistently cooperative setup.
Experimental URL blocklists and allowlists
Puppeteer’s ConnectOptions reference documents experimental blocklist and allowlist options based on the standard URLPattern API. The current reference describes these options as Chrome-only. A matching blocklist pattern causes matching navigations and subresource requests to fail.
These options operate at browser attachment rather than in a page event handler. Verify your installed Puppeteer version and browser before relying on them, because the documentation snapshot identifies the feature as experimental.
An allowlist is not a complete network sandbox. Chrome can reach the network through paths or features that bypass the network service. For isolation boundaries, use container- or operating-system-level controls. Use an allowlist to constrain application behavior, not as a security guarantee against a hostile page.
Rank #3
- Dual band router upgrades to 1200 Mbps high speed internet (300mbps for 2.4GHz plus 900Mbps for 5GHz), reducing buffering and ideal for 4K stream
- Full Gigabit Ports - Gigabit Router with 4 Gigabit LAN ports, ideal for any internet plan and allow you to directly connect your wired devices
- Boosted Coverage - Four external antennas equipped with Beamforming technology extend and concentrate the Wi-Fi signals
- MU-MIMO technology - (5GHz band) allows high speeds for multiple devices simultaneously
- Access Point Mode - Supports AP Mode to transform your wired connection into wireless network, an ideal wireless router for home
Complete example: blocking known third-party traffic
This runnable script combines host and resource-type rules, logs decisions, waits for a stable page, and writes a screenshot.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
const blockedHosts = new Set([
'ads.example.test',
'metrics.example.test'
]);
const blockedTypes = new Set(['media']);
await page.setRequestInterception(true);
page.on('request', request => {
if (request.isInterceptResolutionHandled()) return;
let hostname;
try {
hostname = new URL(request.url()).hostname;
} catch {
return request.continue();
}
if (blockedHosts.has(hostname) || blockedTypes.has(request.resourceType())) {
console.log('ABORT', request.resourceType(), request.url());
return request.abort();
}
console.log('ALLOW', request.resourceType(), request.url());
return request.continue();
});
try {
await page.goto('https://example.com', {
waitUntil: 'networkidle2',
timeout: 60000
});
await page.screenshot({path: 'clean.png', fullPage: true});
} finally {
await browser.close();
}
})();
Replace the example domains with rules validated against your site. Keep the timeout finite, and always close the browser in a finally block so failed navigations do not leak Chromium processes.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteTroubleshooting
The page hangs after interception is enabled
Most often, a handler returned without calling continue, abort, or respond. Add a default continuation and log every branch. Also check for a second handler that resolved the request first.
“Request is already handled” or duplicate-resolution errors
Multiple listeners raced. Guard every listener with isInterceptResolutionHandled(), and repeat the guard after each asynchronous operation. Alternatively, consolidate policy into one handler.
Blocking ads removes application features
The domain may host both advertising and required APIs, or your resource-type rule may be too broad. Narrow the match to an exact hostname and path, allow first-party traffic, and test navigation, forms, and authentication separately.
The tracker still appears in logs
A page may use a different hostname, a redirect, a service worker, or cached content. Log the complete URL and resource type, inspect redirects, and test with a fresh browser context. Update the rule only after confirming the actual request.
An allowlist does not stop all outbound traffic
That behavior is expected: the documented allowlist is not a full sandbox. Enforce isolation outside Puppeteer with container or OS networking controls.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Performance, reliability, and cost considerations
Interception adds JavaScript work for every surfaced request. Keep matching operations simple (sets and precompiled patterns), avoid network calls inside the handler, and avoid awaiting asynchronous policy unless you need it. Broad logging can become the bottleneck on pages with many resources, so make verbose logs configurable.
Blocking third-party scripts can improve load time, but aborting fonts, CSS, or images may cause layout shifts and change screenshots. Measure the page state you actually care about: a visual baseline, a functional test, or a reduced-bandwidth crawl. Use explicit navigation and selector waits when network-idle never occurs because analytics or long polling remains active.
Rank #4
- Dual-band Wi-Fi with 5 GHz speeds up to 867 Mbps and 2.4 GHz speeds up to 300 Mbps, delivering 1200 Mbps of total bandwidth¹. Dual-band routers do not support 6 GHz. Performance varies by conditions, distance to devices, and obstacles such as walls.
- Covers up to 1,000 sq. ft. with four external antennas for stable wireless connections and optimal coverage.
- Supports IGMP Proxy/Snooping, Bridge and Tag VLAN to optimize IPTV streaming
- Access Point Mode - Supports AP Mode to transform your wired connection into wireless network, an ideal wireless router for home
- Advanced Security with WPA3 - The latest Wi-Fi security protocol, WPA3, brings new capabilities to improve cybersecurity in personal networks
Request interception runs inside each browser process you operate. Your cost and capacity therefore include Chromium memory, startup time, concurrency limits, proxy or egress charges, and maintenance of domain rules. If your goal is simply a clean screenshot, an API can remove that browser operational burden.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteOr skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. It accepts consent banners before capture, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn each cleanup step off. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with the result identified by X-Page-Verdict and X-Billed headers.
One GET request returns PNG, JPEG, WebP, or PDF. The API also supports blocking ads, trackers, requests, or resource types; custom CSS and JavaScript; selector waits; cookies and headers; device and viewport settings; full-page and element captures; caching; bulk jobs; and signed webhooks. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
See the ScreenshotNeo API documentation for authentication and all options. The following calls use the supplied API format.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
The Free plan includes 1,000 shots per month with no card. Starter is $5 for 3,000 shots, Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000; yearly billing gives two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to start without a card.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →FAQ
Does interception block requests made before the handler is registered?
No. Enable interception and register the listener before navigation or any action that triggers the traffic you want to control.
Can Puppeteer identify every ad or tracker automatically?
No. The API supplies request data and control methods, but you must create and maintain rules for the domains, paths, or resource types relevant to your targets.
Should I use an allowlist for security isolation?
No. The documented allowlist is experimental, Chrome-only, and explicitly not a complete network sandbox. Use OS- or container-level isolation for that requirement.
Frequently Asked Questions
Can interception affect screenshots?
Yes. Blocking CSS, fonts, images, or scripts can change layout and rendering. Validate visual output after each rule change.
What is the safest default handler?
Continue every request unless a narrowly tested rule matches; always guard against another handler resolving it first.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

