A Svelte/SvelteKit action for lazy-loading images with IntersectionObserver and built-in cache reuse. Current stable version is 1.0.9-remake (note: semver-like but with '-remake' suffix, indicating a special release). It checks a browser cache before fetching images from the network; subsequent loads with the same src use the cached image, reducing network requests. Key differentiators: lightweight, no additional dependencies, provides custom events (cacheload, imgload) for tracking load sources. Release cadence is irregular; the package has only a few versions. Suitable for image-heavy Svelte apps wanting to minimize bandwidth.
npm install svelte-lazyimage-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use the lazyimage action with caching enabled, placeholder src, and custom events for load source tracking.
Pin to this specific version in package.json: "svelte-lazyimage-cache": "1.0.9-remake" and update manually when new versions appear.
Add an IntersectionObserver polyfill (e.g., core-js or intersection-observer) for older browsers.
Review changelog when updating and adapt to any new configuration API.
Use on:cacheload and on:imgload in Svelte templates. For programmatic usage, use element.addEventListener with caution.
If you get build errors in production, move it to dependencies: npm install svelte-lazyimage-cache (without --save-dev).
Ensure the package is in your dependencies (npm install svelte-lazyimage-cache) and import using: import { lazyimage } from 'svelte-lazyimage-cache'.Install and import an IntersectionObserver polyfill in your app entry point: npm install intersection-observer and then 'intersection-observer'.
Ensure the action is used on a valid HTML element, e.g., <img use:lazyimage> and that the element is mounted before the action runs.
Use consistent URLs (same protocol, no random query strings) for the same image. The cache is a simple object mapping URLs to cached Image objects.
No dependency data recorded yet.