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.

How Block Resources works

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.

Basic usage

Add the block_resources parameter with comma-separated resource types to your request:
# pip install requests
import requests

url = 'https://httpbin.io/anything'
apikey = 'YOUR_ZENROWS_API_KEY'
params = {
    'url': url,
    'apikey': apikey,
    'js_render': 'true',
    'block_resources': 'image,media,font',
}
response = requests.get('https://api.zenrows.com/v1/', params=params)
print(response.text)
This example blocks images, media files, and fonts while allowing other resources to load normally, resulting in faster page loading and reduced data usage.

Available resource types

ZenRows supports blocking the following resource types:

Content resources

  • stylesheet - CSS files that define visual styling and layout
  • image - All image formats including JPG, PNG, GIF, SVG, and WebP
  • media - Audio and video files of all formats
  • font - Web fonts including WOFF, WOFF2, TTF, and OTF files

Script and dynamic content

  • script - JavaScript files and inline scripts
  • xhr - XMLHttpRequest calls used for AJAX functionality
  • fetch - Modern Fetch API requests for dynamic content loading
  • eventsource - Server-sent events for real-time data streams
  • websocket - WebSocket connections for bidirectional communication

Application resources

  • texttrack - Video subtitle and caption files
  • manifest - Web app manifests containing application metadata
  • other - Any resource types not specifically categorized above

Special values

  • none - Disables all resource blocking, allowing everything to load

When to use Block Resources

Block Resources is essential for these scenarios:

Performance optimization:

  • Large-scale scraping - Reduce bandwidth and processing time across many requests
  • Content-heavy sites - Skip images and media when extracting text data
  • Slow connections - Minimize data transfer in bandwidth-limited environments
  • High-volume operations - Optimize resource usage for continuous scraping tasks
  • Cost reduction - Lower bandwidth costs for cloud-based scraping operations

Content-specific extraction:

  • Text-only scraping - Extract articles, reviews, or descriptions without visual elements
  • Data mining - Focus on structured data while ignoring presentation layers
  • API monitoring - Allow dynamic requests while blocking static resources
  • Search engine optimization - Analyze content structure without styling interference
  • Accessibility testing - Test content availability without visual dependencies

Troubleshooting and debugging:

  • JavaScript conflicts - Isolate issues by selectively blocking script types
  • Loading problems - Identify problematic resources causing page failures
  • Performance analysis - Measure impact of different resource types on loading speed
  • Content validation - Verify that essential content doesn’t depend on blocked resources

Disabling resource blocking

To turn off ZenRows’ default resource blocking and allow all content to load:
Python
params = {
    'js_render': 'true',
    'block_resources': 'none',  # Disable all resource blocking
}
Use block_resources=none when:
  • You need complete visual fidelity
  • Debugging layout or styling issues
  • Testing how pages appear to real users
  • Analyzing complete resource loading patterns
  • Ensuring no content dependencies are missed

Best practices

Monitor content integrity

Verify that blocked resources don’t affect essential content:
Python
def validate_content_integrity(url, target_selectors):
    """
    Compare content availability with and without resource blocking
    """
    from bs4 import BeautifulSoup
    
    # Test with default blocking
    default_response = requests.get('https://api.zenrows.com/v1/', params={
        'url': url,
        'apikey': 'YOUR_ZENROWS_API_KEY',
        'js_render': 'true',
    })
    
    # Test with aggressive blocking
    aggressive_response = requests.get('https://api.zenrows.com/v1/', params={
        'url': url,
        'apikey': 'YOUR_ZENROWS_API_KEY',
        'js_render': 'true',
        'block_resources': 'image,media,font,stylesheet,script',
    })
    
    default_soup = BeautifulSoup(default_response.text, 'html.parser')
    aggressive_soup = BeautifulSoup(aggressive_response.text, 'html.parser')
    
    integrity_report = {}
    
    for selector in target_selectors:
        default_elements = default_soup.select(selector)
        aggressive_elements = aggressive_soup.select(selector)
        
        integrity_report[selector] = {
            'default_count': len(default_elements),
            'aggressive_count': len(aggressive_elements),
            'content_preserved': len(default_elements) == len(aggressive_elements),
        }
    
    return integrity_report

# Validate that important content is preserved
selectors = ['.product-title', '.price', '.description', '.reviews']
integrity = validate_content_integrity('https://ecommerce.com/product/123', selectors)

for selector, data in integrity.items():
    status = "✓" if data['content_preserved'] else "✗"
    print(f"{status} {selector}: {data['default_count']}{data['aggressive_count']} elements")

Combine with other parameters

Use Block Resources with complementary features for optimal results:
Python
params = {
    'js_render': 'true',
    'block_resources': 'image,media,font,stylesheet',  # Block visual resources
    'wait_for': '.main-content',                       # Wait for essential content
    'json_response': 'true',                          # Capture API calls
    'premium_proxy': 'true',                          # For protected sites
}

Troubleshooting

Common issues and solutions

IssueCauseSolution
Missing contentEssential scripts blockedRemove script from blocked resources
Incomplete dataXHR/Fetch requests blockedAllow xhr and fetch resources
Layout issuesCSS dependenciesRemove stylesheet from blocking
Slow loadingToo many resources allowedAdd more resource types to blocking
JavaScript errorsFont or media dependenciesTest with individual resource types

Debugging missing content

When content disappears after blocking resources:
1

Compare HTML outputs

Compare the HTML obtained with and without resource blocking to identify missing elements.
Python
# Get baseline without custom blocking
baseline = requests.get('https://api.zenrows.com/v1/', params={
    'url': url,
    'apikey': 'YOUR_ZENROWS_API_KEY',
    'js_render': 'true',
})
# Get result with blocking
blocked = requests.get('https://api.zenrows.com/v1/', params={
    'url': url,
    'apikey': 'YOUR_ZENROWS_API_KEY',
    'js_render': 'true',
    'block_resources': 'image,media,font,script',
})

print(f"Baseline length: {len(baseline.text)}")
print(f"Blocked length: {len(blocked.text)}")
2

Test individual resource types

Block one resource type at a time to identify the problematic category.
Python
resource_types = ['image', 'media', 'font', 'stylesheet', 'script', 'xhr']

for resource_type in resource_types:
    response = requests.get('https://api.zenrows.com/v1/', params={
        'url': url,
        'apikey': 'YOUR_ZENROWS_API_KEY',
        'js_render': 'true',
        'block_resources': resource_type,
    })
    
    # Check if target content exists
    has_content = 'target-selector' in response.text
    print(f"Blocking {resource_type}: Content present = {has_content}")
3

Adjust blocking strategy

Remove problematic resource types from your blocking configuration.
Python
# If script blocking causes issues, exclude it

safe_blocking = 'image,media,font,stylesheet'  # Exclude script, xhr, fetch
response = requests.get('https://api.zenrows.com/v1/', params={
    'url': url,
    'apikey': 'YOUR_ZENROWS_API_KEY',
    'js_render': 'true',
    'block_resources': safe_blocking,
})

Performance vs. content trade-offs

Balance optimization with content completeness:
Python
def find_optimal_blocking(url, required_selectors):
    """
    Find the most aggressive blocking that preserves required content
    """
    blocking_configurations = [
        'image',
        'image,media',
        'image,media,font',
        'image,media,font,stylesheet',
        'image,media,font,stylesheet,other',
    ]
    
    optimal_config = None
    
    for config in blocking_configurations:
        response = requests.get('https://api.zenrows.com/v1/', params={
            'url': url,
            'apikey': 'YOUR_ZENROWS_API_KEY',
            'js_render': 'true',
            'block_resources': config,
        })
        
        from bs4 import BeautifulSoup
        soup = BeautifulSoup(response.text, 'html.parser')
        
        # Check if all required content is present
        all_content_present = all(
            soup.select(selector) for selector in required_selectors
        )
        
        if all_content_present:
            optimal_config = config
            print(f"✓ Configuration '{config}' preserves all content")
        else:
            print(f"✗ Configuration '{config}' missing content")
            break
    
    return optimal_config

# Find optimal blocking for specific content requirements
required_elements = ['.product-title', '.price', '.description']
best_config = find_optimal_blocking('https://shop.com/product/123', required_elements)
print(f"Recommended blocking: {best_config}")

Pricing

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.

Frequently Asked Questions (FAQ)