react-lottie icon indicating copy to clipboard operation
react-lottie copied to clipboard

Large Lottie json increases bundle size.

Open krishnagogada opened this issue 3 years ago • 1 comments

I have Lottie JSON file with 500KB. If I keep it in the public folder, it will increase the bundle size.

Is there any best practice to use Lottie JSON file and not increase the bundle size?

krishnagogada avatar Jun 11 '22 11:06 krishnagogada

Have you tried dynamically importing the json file as an object with await import("./lottie.json")?

I'm using next.js and my json file is excluded from the main bundle when I dyamically import the json into a state variable within a useEffect hook. Then, I pass that value into the animationData member of the options prop in the <Lottie /> component.

jonator avatar Aug 24 '22 19:08 jonator