Skip to content

Block resources without request interception

berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘ edited this page Nov 14, 2020 · 5 revisions
const blockedResources = [
  // Assets
  '*/favicon.ico',
  '.css',
  '.jpg',
  '.jpeg',
  '.png',
  '.svg',
  '.woff',

  // Analytics and other fluff
  '*.optimizely.com',
  'everesttech.net',
  'userzoom.com',
  'doubleclick.net',
  'googleadservices.com',
  'adservice.google.com/*',
  'connect.facebook.com',
  'connect.facebook.net',
  'sp.analytics.yahoo.com',
]

await page._client.send('Network.setBlockedURLs', { urls: blockedResources });

Note: The above will use the underlying CDP (Chrome Devtools Protocol) directly, documentation for Network.setBlockedURLs can be found here.

Clone this wiki locally