-
-
Notifications
You must be signed in to change notification settings - Fork 772
Block resources without request interception
berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘ edited this page Jun 25, 2022
·
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',
]
// puppeteer >= 14.4.1: page._client -> page._client()
const client = typeof page._client === 'function' ? page._client() : page._client
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.