```yaml
product: AlterLab
title: "Lazy Loading — Web Scraping Glossary | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/glossary/lazy-loading
```

general

# Lazy Loading

Lazy loading defers fetching images or content until the user scrolls them into view, reducing initial page load time but requiring scrapers to trigger scroll events to access deferred content.

Browsers support native lazy loading via the `loading='lazy'` attribute on `<img>` and `<iframe>` elements, which defers their fetch until they approach the viewport. JavaScript frameworks also implement lazy loading for arbitrary content using IntersectionObserver: when a placeholder element scrolls into view, JavaScript replaces it with the actual content.

For HTML-only scrapers, lazy-loaded images appear in the raw HTML as empty `<img>` tags with their actual URL in a `data-src` attribute rather than `src`. The actual image is only fetched when `src` is populated by JavaScript after scroll. Extracting the real URL requires either executing the page's JavaScript or reading the `data-src` attribute directly.

For lazy-loaded text content (common in social feeds and virtual-scroll lists), a headless browser is required to simulate scrolling and wait for the IntersectionObserver to populate the content. See also: Infinite Scroll.

### What is Lazy Loading?

Lazy loading defers fetching images or content until the user scrolls them into view, reducing initial page load time but requiring scrapers to trigger scroll events to access deferred content.

### How does AlterLab handle Lazy Loading?

For lazy-loaded text content (common in social feeds and virtual-scroll lists), a headless browser is required to simulate scrolling and wait for the IntersectionObserver to populate the content. See also: Infinite Scroll.

## Examples

```
# Extract lazy-loaded image URLs from data-src
from bs4 import BeautifulSoup

soup = BeautifulSoup(html, "html.parser")
images = []
for img in soup.find_all("img"):
    src = img.get("data-src") or img.get("src") or img.get("data-lazy-src")
    if src:
        images.append(src)
```

## Related Terms

[Infinite ScrollInfinite scroll is a UX pattern where additional content loads automatically as the user scrolls toward the bottom of the page, replacing traditional pagination.](https://alterlab.io/glossary/infinite-scroll)[Dynamic ContentPage content generated client-side by JavaScript after the initial HTML is served, requiring a browser engine to render.](https://alterlab.io/glossary/dynamic-content)[JavaScript RenderingThe process of executing a page's JavaScript in a browser engine before extracting content, required for React, Vue, and Angular SPAs.](https://alterlab.io/glossary/javascript-rendering)[Headless BrowserA web browser that runs without a graphical user interface, executing JavaScript and rendering pages exactly as a real browser would.](https://alterlab.io/glossary/headless-browser)[DOM (Document Object Model)The tree-structured programmatic representation of a web page that JavaScript manipulates to create dynamic content.](https://alterlab.io/glossary/dom)

## Extract Lazy Loading data from any website

AlterLab returns clean, structured data from any public URL — no scraper infrastructure needed. Start free, no credit card required.

[View API docs](https://alterlab.io/docs/api/rest)

[Back to Glossary](https://alterlab.io/glossary)