Why download and process data that you won’t be using? You can speed up your scraping by blocking resources in headless browsers. ZenRows also allows that option when using JavaScript Rendering (js_render set to true).

If you are testing from the Builder, check “JavaScript Rendering” and then “Block Resources”. It will display a list of resource types that can be blocked (i.e., stylesheet or image). The parameter added is block_resources, and the blocked types are a list separated by a comma.

Block Resources Builder

The headless browser will effectively avoid downloading all the resources that match the types you send. Following the example, the browser will omit CSS stylesheets and images. Depending on the website you’re scraping, that can cut the time in half.

curl "https://api.zenrows.com/v1/?apikey=YOUR_ZENROWS_API_KEY&url=YOUR_URL&js_render=true&block_resources=stylesheet%2Cimage"

You can combine this parameter with, for example, wait for selector. The content will be loaded with a headless browser and wait for the selector to be present. It means that unless javascript or XHR are blocked, dynamic content will load. At the same time, images, CSS, and fonts might be blocked to speed up the process.

curl "https://api.zenrows.com/v1/?apikey=YOUR_ZENROWS_API_KEY&url=YOUR_URL&js_render=true&wait_for=.custom-selector&block_resources=stylesheet%2Cfont%2Cimage"

Troubleshooting

Sometimes blocking particular resources, especially javascript files, will end up in an error or content missing. That might happen, for example, when the target website expects XHR calls after the initial render.

To test that it works appropriately, compare the Plain HTML obtained with ZenRows and a sample obtained by hand. The HTML should be similar unless there is some problem. If you need an element that does not appear, test again by removing the blocked resources (probably javascript or XHR).

If the problem remains, contact us and we’ll help you.