{% extends "django_sample_components/pages/master_async.html" %} {% load async_tags %} {% block title %}Async Lazy Load{% endblock %} {% block content %}

Async Lazy Load with HTMX

This component loads server content only when it becomes visible in the viewport.


Scroll down to trigger each lazy-loading example. Delay is configured in milliseconds.

1. Default call (no options)

Uses the default internal URL (/async/lazy-load), default placeholder and no delay.

{% async_lazy_load %}

2. Custom placeholder (no delay)

Only customizes the waiting message.

{% async_lazy_load placeholder="Custom placeholder: waiting for visibility in viewport..." %}

3. Delay only

Forces a 1200ms response delay while keeping the default placeholder.

{% async_lazy_load delay_ms=1200 %}

4. Internal custom URL + delay

Uses an explicit internal URL and a 2500ms forced delay.

{% async_lazy_load url="/async/lazy-load/" placeholder="Preparing delayed content from internal URL..." delay_ms=2500 %}

5. External URL (outside this project)

Loads Google via an internal proxy endpoint, avoiding browser CORS limitations.

{% async_lazy_load url="/async/lazy-load/external/?target_url=https://www.google.com" placeholder="Loading Google through internal proxy..." delay_ms=150 %}

6. Custom placeholder + delay

Combines a custom message with a 2500ms forced delay.

{% async_lazy_load placeholder="Preparing delayed content from server..." delay_ms=2500 %}

7. Explicit zero delay

Behaves like immediate loading, but with delay configured explicitly.

{% async_lazy_load placeholder="No artificial delay (delay_ms=0)." delay_ms=0 %}

8. Lazy load full counter component (2s)

Loads the full counter component (+/- buttons and value) after a forced 2000ms delay.

{% async_lazy_load url="/async/counter/component/?initial_value=10&step=2&min_value=0&max_value=20" placeholder="Loading full counter component (2 seconds)..." delay_ms=2000 %}
{% endblock %}