/** * Lazy Loading Strategies for LadrillosJS * * control over when lazy components are loaded. */ /** * A lazy loading strategy function. * @param load - Call this to trigger component loading * @param element - The placeholder element being observed * @returns Optional teardown function for cleanup */ export type LazyStrategy = (load: () => void, element: Element) => (() => void) | void; /** * Factory function that creates a LazyStrategy with options */ export type LazyStrategyFactory = T extends undefined ? () => LazyStrategy : (options?: T) => LazyStrategy; /** * Load when the browser is idle. * Uses requestIdleCallback with a timeout fallback. * * @param timeout - Max wait time in ms before forcing load (default: 10000) * * @example * { name: 'analytics', path: './analytics.html', lazy: lazyOnIdle(5000) } */ export declare const lazyOnIdle: LazyStrategyFactory; /** * Load when element becomes visible in viewport. * Uses IntersectionObserver for efficient visibility detection. * * @param options - IntersectionObserver options (rootMargin, threshold, etc.) * * @example * // Load when 100px before entering viewport * { name: 'footer', path: './footer.html', lazy: lazyOnVisible({ rootMargin: '100px' }) } */ export declare const lazyOnVisible: LazyStrategyFactory; /** * Load when specified media query matches. * Useful for mobile-only or desktop-only components. * * @param query - CSS media query string * * @example * { name: 'mobile-nav', path: './mobile-nav.html', lazy: lazyOnMedia('(max-width: 768px)') } */ export declare const lazyOnMedia: LazyStrategyFactory; /** * Load when user interacts with the element. * Replays the triggering event after component loads for seamless UX. * * @param events - Event type(s) to listen for (default: ['click', 'focusin']) * * @example * { name: 'modal', path: './modal.html', lazy: lazyOnInteraction('click') } * { name: 'form', path: './form.html', lazy: lazyOnInteraction(['focus', 'click']) } */ export declare const lazyOnInteraction: LazyStrategyFactory; /** * Load after a specified delay. * Simple time-based loading for non-critical components. * * @param ms - Delay in milliseconds * * @example * { name: 'chat-widget', path: './chat.html', lazy: lazyOnDelay(3000) } */ export declare const lazyOnDelay: LazyStrategyFactory; /** * Default lazy strategy - loads when visible with 100px root margin * for smooth loading before element enters viewport */ export declare const defaultLazyStrategy: LazyStrategy;