How to Handle Infinite Scrolling and Dynamic Loading with Gaffa’s Scroll Action

Gaffa's scroll action gives you fine-grained control over exactly how your automation scrolls down the page on modern sites that use lazy loading and infinite scrolling

How to Handle Infinite Scrolling and Dynamic Loading with Gaffa’s Scroll Action

Automating scrolling on websites isn't simple. Modern web apps often use scrolling to control when and how content loads through lazy loading and infinite scrolling. Others add delays, pop-ups, or rate limits to slow down automation. If you're using frameworks like Playwright or Selenium, handling scrolling means writing dozens of lines of code, testing different methods, and still risking detection.

Gaffa gives you a huge amount of control over how your browser automation scrolls through a number of configurable settings, whether you want to immediately scroll to the desired location or mimic human behavior, reducing the risk of being blocked.


Using the Gaffa demo site, the API Playground, and the following examples, you will be able to see how adjusting small parameter changes allows you to:
  • Control scrolling speed for smoother and more natural automation.
  • Use immediate scrolls with intervals to respect rate limits.
  • Scroll to the bottom of the page to load all content before capturing a screenshot.
  • Configure the wait times to handle slow or heavy pages.
  • Set maximum scroll times for infinite scroll, which ensures the scroll doesn’t run forever.

Why Scroll Handling Matters

It reduces the risk of detection and blocking - out of the box web automation frameworks scroll unnaturally, which can trigger anti-bot systems. Gaffa lets you moderate speed and mimic human-like behavior without writing any code.
Most modern sites only load items when scrolled into view. Without controlled scrolling, your automation might miss important content and you'll see an incomplete DOM or unloaded images. The scroll action lets you tune waits and intervals to ensure you capture complete, clean data.

Practical Scrolling Scenarios with Gaffa

Now let's explore how Gaffa makes it easy to handle a variety of real-world scrolling needs. You can try all the examples below as you read using the API Playground.
These examples use Gaffa's Demo Site and the e-commerce storefront sample as a target for the automation. The site's behaviour can tailored to reflect different scenarios using url parameters and also configurable from the home page. The following settings are configurable and used in the samples below:
  • Load time
  • Cookie modal display and delay - optionally display a cookie modal after a supplied time
  • Item count - a particular item count or infinite for infinite scrolling pages
  • Item load time - how long the items and subsequent batches take to load

Scenario 1: Changing Scroll Speed

One of the simplest ways to control automation is by adjusting scroll speed. Scrolling too fast can look “bot-like” or cause content to fail to load, while a natural pace makes your automation appear human and allows the page enough time to render all the content. Gaffa’s scroll action makes this easy with configurable scroll_speed and interval parameters, giving you 3 speed settings:
  • instant - smoothly scroll to the desired position immediately
  • medium - human-like scrolling at a normal speed
  • slow - very slow human-like scrolling, comparable to reading while scrolling
Note: All time-based parameters in Gaffa (e.g., timeout, wait_time, max_scroll_time) are specified in milliseconds.
Example: Instant Scroll
Here’s a request to scroll through an e-commerce storefront on the demo site at an instant speed:
Instant Scroll: Request
This returns JSON output with a link to a screen recording of the action:
Instant Scroll: Response
Example: Slow Scroll
The scroll behavior can be changed by adjusting the scroll_speed value, here we've changed to a slow scroll.
Slow Scroll: Request
Example: Instant Scroll with Interval
For pages that load content dynamically with rate limits, combine scroll_speed with interval to scroll and insert pauses between scroll events to have finer grained control over the speed and avoid limits:
Instant Scroll with Interval: Request
Tip: The `timeout` is used here to define the maximum time Gaffa will wait for the page to become scrollable.

Scenario 2: Full Page Screenshot with Image Loading

Taking screenshots is a common web automation task and can be quite simple, unless the page you want to take a screenshot of relies on lazy-loading, then taking a screenshot of the full height without scrolling first will leave you with missing content or placeholders.
With Gaffa, you can solve this by combining the scroll action with the screenshot action. By setting the scroll percentage to 100, Gaffa will automatically scroll to the bottom of the page, ensuring all items are loaded then, using the capture_screenshot action, capture a fullscreen screenshot of the entire page.
Scroll to Bottom for Screenshot: Request
Here's the captured image.

Scenario 3: Handling a Slow Loading Site

Some sites have unpredictable loading times, where it’s not obvious when scrolling is complete. If you stop as soon as you reach the bottom of the page, you may miss items that are still being loaded. Gaffa can handle this with the wait_time parameter. Instead of ending the scroll request immediately, you can wait a certain amount of time for more items to load. If more items load before the full wait_time elapses, Gaffa will resume scrolling immediately.
Infinite Scroll on Slow Site: Request

Scenario 4: Time-Limited Infinite Scrolling

For infinite scroll pages that could theoretically scroll forever, use max_scroll_time to set reasonable time limits for your request.
Infinite Scroll with Time Limit: Request
You can also use Gaffa's request-level time limits as an additional safety net to prevent runaway requests.
With tools like Playwright or Selenium, handling all these scenarios requires lots of custom code, adding sleep timers, and carefully testing each approach. You might also need to write site-specific code for different sites, as each site has unique requirements. Gaffa makes this entire process effortless. With a single scroll action and a few parameters, you can easily adjust the speed, wait times, take screenshots or limit infinite scrolling.
Scrolling is just one of the many powerful browser actions in Gaffa.
Gaffa Team
Gaffa Team Posts from the Gaffa Team