@academix-admin/lottie-cache
v0.1.0
Published
Tiny in-memory cache + preloader for Lottie animation JSON.
Maintainers
Readme
@academix-admin/lottie-cache
A tiny in-memory cache + preloader for Lottie animation JSON, so the same animation isn't fetched twice. Framework-agnostic — no React required.
Install
npm install @academix-admin/lottie-cacheUsage
import { preloadLottie, getCachedLottie } from '@academix-admin/lottie-cache';
// Preload (e.g. on app start or route hover):
const data = await preloadLottie('spinner', '/animations/spinner.json');
// Later, read synchronously from cache (null if not preloaded):
const cached = getCachedLottie('spinner');API
preloadLottie(id: string, src: string): Promise<any>— fetch (if needed) and cache the animation JSON underid, returning it.getCachedLottie(id: string): any | null— synchronous cache read.
License
MIT © Academix
