The Block Resources parameter prevents your headless browser from downloading specific types of content that aren’t essential for your scraping task. By blocking unnecessary resources, such as images, stylesheets, fonts, and media files, you can significantly improve scraping efficiency, reduce loading times, optimize performance, and minimize bandwidth usage.When you block resources, ZenRows instructs the browser to ignore requests for the specified content types, allowing pages to load faster and consume less data. This is particularly valuable when scraping content-heavy sites where you only need the text data or specific elements.
ZenRows automatically blocks certain resource types by default, such as stylesheets and images, to optimize scraping speed and reduce unnecessary data load. We recommend only using this parameter when you need to customize the default blocking behavior or when troubleshooting specific issues.
Block Resources operates at the network level within the browser, intercepting requests for specified resource types before they’re downloaded. When the browser encounters a request for a blocked resource type, it prevents the download entirely, reducing both loading time and bandwidth consumption.This process affects:
Page loading speed by eliminating unnecessary downloads
Bandwidth usage by preventing large file transfers
Memory consumption by reducing the amount of data processed
Rendering time by focusing only on essential content
Network request volume by filtering out non-critical resources
The blocking happens transparently during page rendering, ensuring that essential functionality remains intact while removing unnecessary overhead.
This example blocks images, media files, and fonts while allowing other resources to load normally, resulting in faster page loading and reduced data usage.
The block_resources parameter doesn’t increase the request cost. You pay the JavaScript Render (5 times the standard price) regardless of the wait value you choose.
ZenRows automatically blocks stylesheets and images by default to optimize scraping speed and reduce data usage. You can override this behavior by setting block_resources=none to allow all resources, or by specifying custom blocking for specific resource types.
Will blocking JavaScript break dynamic content loading?
Yes, blocking scripts can prevent dynamic content from loading properly. If you need content that’s loaded via JavaScript, avoid blocking the script, xhr, and fetch resource types. Focus on blocking visual resources like image, media, font, and stylesheet instead.
How much bandwidth can I save by blocking resources?
Bandwidth savings vary significantly depending on the website’s content and design. Image-heavy sites can significantly reduce data transfer by blocking images and media. Text-focused sites may achieve savings by blocking stylesheets and fonts.
Can I block resources when not using js_render?
No, the block_resources parameter only works with js_render=true because resource blocking operates within the browser environment during JavaScript rendering. For static HTML requests, resource blocking isn’t applicable.
What happens if I block XHR or Fetch requests?
Blocking XHR or Fetch requests prevents the page from making AJAX calls, which can result in missing dynamic content. Only block these if you’re certain the content you need is available in the initial HTML without requiring additional API calls.
Does blocking resources affect the JSON Response feature?
Yes, if you block xhr or fetch resources, those requests won’t appear in the JSON Response XHR array. However, blocking visual resources, such as images and stylesheets, won’t affect the capture of API calls and can reduce the overall response size.
Can I use wildcards or patterns in resource blocking?
No, you must specify exact resource type names from the supported list. You cannot use wildcards or custom patterns. To block multiple types, separate them with commas, such as image,media,font.
How do I know which resources are safe to block for my use case?
Start by blocking only visual resources (image,media,font,stylesheet) and test if your target content is still available. If content is missing, remove resource types one by one until you find the minimal blocking configuration that preserves your required data.