Files
cfw-autumn/apps/website/lib/lazyGsap.ts
Debosmit Majumder 90125fde21 GSAP optimisation
2026-04-28 14:30:03 +05:30

11 lines
339 B
TypeScript

// Loads GSAP exactly once — first call triggers the dynamic import,
// subsequent calls reuse the same promise.
type Gsap = (typeof import("gsap"))["default"];
let promise: Promise<Gsap> | null = null;
export const getGsap = (): Promise<Gsap> => {
if (!promise) promise = import("gsap").then((m) => m.default);
return promise;
};