Open krishnagogada opened 2 years ago
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.
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?