Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large Lottie json increases bundle size. #142

Open
krishnagogada opened this issue Jun 11, 2022 · 1 comment
Open

Large Lottie json increases bundle size. #142

krishnagogada opened this issue Jun 11, 2022 · 1 comment

Comments

@krishnagogada
Copy link

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?

@jonator
Copy link

jonator commented Aug 24, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants