Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
ad blocking

How to Block Requests, Ads, and Trackers in Puppeteer

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Puppeteer’s request interception when your code must inspect each page request and then abort it, let it continue, or supply a response. Enable interception with await page.setRequestInterception(true), attach a request listener, and resolve every intercepted request. An unresolved request stalls page activity, so interception rules must always end in request.abort(), request.continue(), or request.respond() (or be served from browser cache).

What Puppeteer request interception actually does

Request interception creates an application-level decision point for network traffic generated by a page. It can cover navigations and subresources such as scripts, images, stylesheets, fonts, XHR, and fetch calls. Your handler can:

  • Abort a request with request.abort().
  • Continue it unchanged, or with modified request data, using request.continue().
  • Fulfill it yourself with request.respond(), returning a status, headers, and body.

Interception is not an automatic ad-blocking database. Puppeteer’s examples demonstrate URL-based filtering, but they do not define a canonical taxonomy of advertising or tracking domains. You must choose, test, and maintain rules that fit your target sites.

Minimal setup that will not hang the page

The following complete example blocks one host and allows everything else. Replace the example host with a domain or pattern you have verified.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
TP-Link AX1800 WiFi 6 Router (Archer AX21 V5)
  • 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.
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 => {
    const url = request.url();

    if (url.includes('example-tracker-domain.test')) {
      return request.abort();
    }

    return request.continue();
  });

  await page.goto('https://example.com', {waitUntil: 'networkidle2'});
  await page.screenshot({path: 'page.png', fullPage: true});
  await browser.close();
})();

Install Puppeteer in the project before running it with npm install puppeteer. The URL test is deliberately illustrative, not a vetted tracker list. Prefer matching a specific hostname or a carefully bounded pattern rather than a broad substring that could block legitimate application traffic.

Building useful blocking rules

Match hosts, paths, and resource types

Parse the URL when you need host-level precision. Resource-type checks are useful when a page’s visual output does not need a class of asset.

const blockedHosts = new Set([
  'ads.example.test',
  'metrics.example.test'
]);

page.on('request', request => {
  const parsed = new URL(request.url());

  if (blockedHosts.has(parsed.hostname)) {
    return request.abort();
  }

  if (request.resourceType() === 'image' && parsed.pathname.endsWith('.gif')) {
    return request.abort();
  }

  return request.continue();
});

Host matching avoids accidentally blocking a similarly named legitimate domain. Path matching can target a known analytics endpoint. Resource-type matching is blunt: blocking images may remove advertisements, but it also removes product images, charts, and icons. Validate the result on every important page template.

Continue, modify, or fulfill a request

Use continue for ordinary traffic. Puppeteer also allows request data to be changed, such as headers or the method, subject to the API’s rules. Use respond when a deterministic local response is preferable to a network call.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page.on('request', request => {
  if (request.url().endsWith('/feature-flags.json')) {
    return request.respond({
      status: 200,
      contentType: 'application/json',
      body: JSON.stringify({ads: false})
    });
  }
  return request.continue();
});

Fulfillment changes application behavior, so keep test fixtures explicit and version-controlled. Do not use it as a substitute for a complete network security boundary.

Interception with multiple handlers

Libraries and your own code can register more than one request handler. Two handlers may try to resolve the same request, especially when one performs asynchronous work. Before resolving, check whether another handler has already done so; check again after every await.

Rank #2
Sale
TP-Link BE6500 Dual-Band WiFi 7 Router (BE400)
  • 𝐅𝐮𝐭𝐮𝐫𝐞-𝐑𝐞𝐚𝐝𝐲 𝐖𝐢-𝐅𝐢 𝟕 - 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.
page.on('request', async request => {
  if (request.isInterceptResolutionHandled()) return;

  const shouldBlock = await shouldBlockUrl(request.url());

  if (request.isInterceptResolutionHandled()) return;

  if (shouldBlock) {
    return request.abort();
  }

  return request.continue();
});

The check and the resolution call should be adjacent synchronous operations. An asynchronous decision can give another listener time to resolve the request first.

Cooperative Intercept Mode and priorities

When every participating handler supplies a numeric priority to abort, continue, or respond, Puppeteer waits for the handlers and chooses the highest-priority resolution. If priorities tie, the documented order is abort, respond, then continue. A handler that omits a priority uses legacy immediate resolution, which changes the coordination model.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page.on('request', request => {
  if (request.isInterceptResolutionHandled()) return;
  return request.continue({}, 0); // default continuation
});

page.on('request', request => {
  if (request.isInterceptResolutionHandled()) return;
  if (request.url().includes('ads.example.test')) {
    return request.abort('blockedbyclient', 10);
  }
  return request.continue({}, 0);
});

Do not add priorities casually. First inspect how every installed handler resolves requests; mixing legacy and cooperative handlers can produce surprising outcomes.

Choosing and validating an ad or tracker list

Puppeteer supplies the interception mechanism, not a maintained ad-filter list. Build rules from the traffic of your own application and validate them against required functionality.

  1. Capture or inspect request URLs while loading representative pages.
  2. Group candidates by hostname, path, and resource type.
  3. Mark each rule as required to block, safe to allow, or uncertain.
  4. Run visual and functional tests after enabling the rule.
  5. Review the list when vendors, consent systems, or application bundles change.

Overly broad rules can break login, payments, embedded video, maps, fonts, or consent flows. A blocked third-party script may also leave a page waiting for a callback; use explicit navigation and selector timeouts so failures are diagnosable.

Blocklist and allowlist options at browser connection

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 entry causes matching network requests, including navigations and subresources, to fail.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
TP-Link AC1200 Gigabit Dual Band WiFi Router (Archer A6)
  • 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

An allowlist is not a complete network sandbox. Chrome can reach the network through other paths or features that bypass the network service. For isolation boundaries, use container- or operating-system-level controls. Verify the browser and Puppeteer version installed in your project before relying on these experimental options; the documentation snapshot covers Puppeteer 25.12.0, while some method pages are from 25.10.0 and 25.11.0.

Performance, reliability, and cost considerations

  • Every request has handler overhead. Keep synchronous URL and resource checks cheap; avoid network calls from the request listener unless you coordinate them carefully.
  • Blocking can speed pages up. Fewer scripts, images, and connections may reduce transfer and execution work, but an essential dependency can cause retries or a failed application.
  • Navigation waits are separate. networkidle2 can remain difficult on pages with long-lived connections. Combine an appropriate wait condition with a selector or explicit timeout for your workflow.
  • Failures are intentional signals. Log the URL, resource type, and abort reason in development so a rule can be traced when a page changes.
  • Cache behavior matters. The interception guide notes that a request can also complete from browser cache; do not assume every visible resource reaches your handler as a fresh network transaction.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

The page never finishes loading

Cause: a handler returned without resolving the request. Fix: ensure every branch calls abort, continue, or respond, and that exceptions are caught or surfaced. Also check whether your navigation wait condition is unsuitable for a page with persistent connections.

“Request is already handled” or duplicate-resolution errors

Cause: multiple handlers raced, often across an await. Fix: call request.isInterceptResolutionHandled() before the decision and immediately after asynchronous work.

Legitimate content disappears

Cause: a substring or resource-type rule is too broad. Fix: switch to exact host or path matching, remove image-wide rules when images are functional content, and test authenticated and unauthenticated pages separately.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Rules behave differently after a Puppeteer upgrade

Cause: interception coordination or experimental connection options can differ by version. Fix: pin and record the installed Puppeteer and browser versions, read the matching API reference, and test Chrome-only options before deployment.

An allowlist still permits unexpected traffic

Cause: the documented allowlist is not a complete isolation boundary. Fix: enforce outbound policy at the container or operating-system level as well.

Rank #4
TP-Link AC1200 WiFi Router Dual Band Wireless Internet Router (Archer A54)
  • 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

Or skip the browser setup

If your goal is a reliable screenshot rather than custom browser automation, ScreenshotNeo exposes a single screenshot API call. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with the result identified by X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

See the complete parameter reference in the ScreenshotNeo documentation. A cURL request is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same request in Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

And 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}`);

ScreenshotNeo supports PNG, JPEG, WebP, and PDF output, full-page captures with lazy images loaded, CSS-selector element shots, custom CSS and JavaScript, click and wait actions, request and resource blocking, headers, cookies, user agents, authorization, geolocation, time zones, transparent backgrounds, resizing, TTL caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, and a usage API. Every feature is on every plan: 1,000 shots per month are free without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

FAQ

Does aborting a request remove an ad from the DOM?

No. It prevents the network request. The page may still leave an empty container or placeholder; hiding or removing that element requires page-side CSS or JavaScript.

Can request interception enforce a security policy?

It is an application-level decision mechanism. It is not a substitute for operating-system or container network isolation, particularly when using an allowlist.

Should I block every third-party request?

No. Third-party requests may provide authentication, payments, fonts, media, or core application data. Start with narrowly scoped, tested rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can request interception enforce a security policy?

It is an application-level decision mechanism, not a substitute for operating-system or container network isolation.

Should I block every third-party request?

No. Third-party requests may provide authentication, payments, fonts, media, or core application data; use narrowly scoped rules.

Quick Recap

SaleBestseller No. 1
TP-Link AX1800 WiFi 6 Router (Archer AX21 V5)
TP-Link AX1800 WiFi 6 Router (Archer AX21 V5)
VPN SERVER: Archer AX21 Supports both Open VPN Server and PPTP VPN Server
$69.99
Bestseller No. 3
TP-Link AC1200 Gigabit Dual Band WiFi Router (Archer A6)
TP-Link AC1200 Gigabit Dual Band WiFi Router (Archer A6)
MU-MIMO technology - (5GHz band) allows high speeds for multiple devices simultaneously
$44.99
Bestseller No. 4
TP-Link AC1200 WiFi Router Dual Band Wireless Internet Router (Archer A54)
TP-Link AC1200 WiFi Router Dual Band Wireless Internet Router (Archer A54)
Supports IGMP Proxy/Snooping, Bridge and Tag VLAN to optimize IPTV streaming
$34.99

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.