Lazy Component

PRO

Performance-optimized lazy loading components with intersection observer, progressive loading, and smart prefetching capabilities for optimal user experience.

Pro Features

Unlock advanced capabilities with the Pro version

Intersection Observer

Viewport detection with customizable threshold and rootMargin

Automatic Retry

Re-attempts a failing load retryCount times, retryDelay apart, then reports it through onError

Performance Analytics

Measured load and visibility timings delivered to analyticsCallback as a typed LazyLoadMetrics object

Batch Loading

Load large lists in optimized batches as they scroll into view

List Virtualization

Optional windowed rendering for very large lists with configurable overscan

Progressive Enhancement

Blur-up placeholders while content loads via enableProgressiveEnhancement and blurDataURL

Smart Prefetching

prefetch prepares below-the-fold content after prefetchDelay so it is ready before the reader arrives

Installation

Install via CLI

npx @moontra/moonui-cli add lazy-component

Usage

Pro Required

Examples

Lazy Image Gallery

PRO

Images decode only as they approach the viewport. aspectRatio reserves the box up front so nothing shifts, blurDataURL paints a placeholder, and priority opts the first tile out of lazy loading.

Pro Required
Gallery image 1
Priority

Progressive Image Loading

PRO

enableProgressiveLoading streams download progress through onProgress, fallbackSrc covers a broken source, and onLoad/onError drive the surrounding UI state.

Pro Required
loading

Lazy List with Batch Loading

PRO

Items arrive in batches as the sentinel scrolls into view. onBatchLoad reports each range, and the scroll container is a focusable region so keyboard users can reach it.

Pro Required
Showing 0 of 100 items

Virtualized List

PRO

enableVirtualization windows the DOM to the visible slice plus overscan rows. Toggle the dataset to see the emptyState branch.

Pro Required
Loading more items...

Progressive Content Loading

PRO

Heavy sections mount only when they approach the viewport. triggerOnce={false} releases a section again once it leaves, keeping long dashboards light.

Pro Required

Smart Prefetching

PRO

prefetch prepares the content prefetchDelay milliseconds after mount without waiting for the viewport, so the card is already rendered by the time the reader scrolls to it. The right-hand card keeps the default viewport-driven behaviour for comparison.

Pro Required

Retry & Error Handling

PRO

When the load callback throws, LazyComponent re-attempts up to retryCount times with retryDelay between attempts and finally reports the failure through onError. Use the button to switch the demo between a healthy and a failing load.

Pro Required
no error reported

Load Analytics

PRO

enableAnalytics turns on timing collection and analyticsCallback receives the measured load and visibility durations, ready to forward to your RUM pipeline.

Pro Required

Scroll to load content

load: 0 ms
visible: 0 ms
pending

Blur-Up Progressive Enhancement

PRO

enableProgressiveEnhancement paints blurDataURL in place of the default skeleton until the section is ready, then fades the real content in over fadeInDuration.

Pro Required
Loading placeholder