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

Bundle size #244

Open
fostimus opened this issue Oct 10, 2023 · 7 comments
Open

Bundle size #244

fostimus opened this issue Oct 10, 2023 · 7 comments

Comments

@fostimus
Copy link

Can someone explain to me the tradeoffs between dotLottie and using json files?

The react player package for dot Lottie files is 2MB... Seems incredibly heavy to send to the browser vs. importing the JSON player and JSON files.

@theashraf
Copy link
Member

@fostimus
while the total unpacked size of the dotlottie player is around 2MB, the minified bundle size is actually just about 105KB. Remember that not all the files from the 2MB are going to be loaded into your bundle. Instead, only the relevant chunks will be included, based on the specific features of the dotlottie player you utilize.

For a better understanding, you can review the bundle sizes on https://bundlephobia.com/package/@dotlottie/react-player@1.6.1 or even test the package out yourself. Hope this helps! :)

Additionally, you can check out the dotlottie playground and inspect the bundle size of the player directly from the network tab in your browser's developer tools.

@xyhxx
Copy link

xyhxx commented Oct 15, 2023

But bundle not only dotlottie, also have lottie_worker, lottie_canvas, lottie_html, lottie_svg...

example:
code-snapshot

vite build(manualChunks):

build: { rollupOptions: { output: { manualChunks: { dotlottie: ["@dotlottie/react-player"] } } } }

demo1

webpack build(splitChunk):

lottie: { name: 'lottie', chunks: 'all', test: /[\\/]node_modules[\\/](@dotlottie)/, priority: 10, reuseExistingChunk: true, },

demo2

@theashraf
Copy link
Member

theashraf commented Oct 17, 2023

@xyhxx, please note that only one module will be lazy-loaded based on the renderer type that your DotLottiePlayer uses. Not all of the modules will be part of your main bundle.

For a more precise bundle size measurement, consider using tools such as size-limit or bundlephobia

@GoodluckH
Copy link

I face the same issue. I deploy on Cloudflare Pages and it seems like the bundle-size not being reduced during the build. CF has a 2mb limit, so the deployment would fail.

@theashraf theashraf reopened this Nov 12, 2023
@Conor-TS
Copy link

Conor-TS commented Dec 1, 2023

I'm seeing the same issue - using @dotlottie/react-player has a really heavy impact on our bundle size.

@qugh
Copy link

qugh commented Mar 12, 2024

the same. it adds ~500kb gzipped

@theashraf
Copy link
Member

theashraf commented Mar 27, 2024

This dotLottie player is built on top of lottie-web, which has a bundle size of approximately 500KB 😞. But recently, we launched a new dotLottie player (dotlottie-web), based on the ThorVG vector graphics renderer. This new player offers a better JS bundle size, and consistent rendering across different platforms(Mobile & Web), thanks to ThorVG's portability.

If the bundle size is a major concern for you, I recommend trying out dotlottie-web. The new dotLottie player's size is roughly 14KB gzipped, but it requires an extra HTTP request for loading the core dotLottie rust player WASM bindings from npm CDN.

For more insights into dotlottie-web and to determine if it suits your needs, you may find this blog post and codepen examples helpful:

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

6 participants