Skip to content
0

katanakit-js / useLazyLoaderInit

Function: useLazyLoaderInit() ​

ts
function useLazyLoaderInit(
   key?, 
   selector?, 
   rootMargin?
): void;

Defined in: src/infrastructure/observer/observer.service.ts:227

Initializes lazy loading for images using IntersectionObserver. Elements matching the selector must have a data-src attribute with the real image URL.

Parameters ​

ParameterTypeDefault valueDescription
keystring"default"A unique identifier for this lazy-loader instance (default: "default").
selectorstring"img[data-src]"CSS selector for lazy-loadable images (default: "img[data-src]").
rootMarginstring"200px"IntersectionObserver root margin (default: "200px").

Returns ​

void

Example ​

ts
useLazyLoaderInit("gallery", "img[data-src]", "300px");

Released under the MIT License.