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] lottie-web is 237.5kB minified— could this be improved? #1184

Open
petermikitsh opened this issue Aug 8, 2018 · 14 comments
Open

Comments

@petermikitsh
Copy link

According to Bundlephobia, lottie-web@5.2.0 is 237.5kB minified, and 60.5kB minified + gzipped.

Are there any potential optimizations that could be made? I'm interested in adopting Lottie, but it has a fairly substantial footprint.

@bodymovin
Copy link
Collaborator

You can use the light version that only supports the svg renderer and no expressions.
https://github.com/airbnb/lottie-web/tree/master/build/player

@petermikitsh
Copy link
Author

For reference, lottie_light is 144kB minified and 38.5kB minified + gzipped. I pulled it from https://unpkg.com/lottie-web@5.2.0/build/player/lottie_light.min.js to check the filesize.

Considering the light version is half the size, are there additional improvements that could be made to make the light version lighter?

@apple77y
Copy link

apple77y commented Jul 3, 2019

Thank you guys for this information!

@tony-topper
Copy link

Not sure light is a fair name when it's nearly 40kb. Should it be called lottie and lottie-full?

@hipstersmoothie
Copy link

This + the actual size of lottie files is are a pretty limiting constraint.

I'm not quite sure this has been optimized for the web, where the first paint depends heavily on the initial js bundle size. On mobile it doesn't matter since it's only experienced at install time, but on web this is critical

@bodymovin
Copy link
Collaborator

Unfortunately, trying to squeeze a good chunk of After Effects into anything smaller than 60Kb is not an easy task :)
Regarding the lottie files themselves, if you consider they hold all the svg data and the animation data, they are usually smaller than coding them by hand.
And it still beats a gif or video in file size.
Having said all that, I completely agree that it's far form ideal.
I'd love to see the WAAPI move forward or css supporting shape animations to delegate compatible animations to native solutions and remove the js part altogether.

@aidanlister
Copy link

aidanlister commented Oct 3, 2020

Is there a way to get the svg only lottie light through npm?

Currently the docs recommend:

import lottie from 'lottie-web'

Could there an option for:

import lottie from 'lottie-web/svg-min'

@bodymovin
Copy link
Collaborator

@aidanlister , you should be able to import it doing
import lottie from 'lottie-web/build/player/lottie_svg.min.js'
or
import lottie from 'lottie-web/build/player/lottie_light.min.js'

@fseminario
Copy link

fseminario commented Mar 23, 2021

How does one define which player to use when its used as part of a build? I know when its specified in html its in the script tag but how do I get it to specifically use lottie_light.js as part of a build?

for example, currently its being called like this:

import lottie from 'lottie-web';

does this mean its calling the lottie.js player? For lottie light would it be like this?

import lottie from 'lottie-light';

or DOES it have to be specified as a the path as mentioned above: lottie-web/build/player/lottie_light.min.js?

@seb-thomas
Copy link

Does anyone know what @bodymovin meant by 'expressions'?

@siskaoffeo
Copy link

Does anyone know what @bodymovin meant by 'expressions'?

@seb-thomas they are referring to After Effect expression. In AE, you can put JS Code into animated properties. So, if the person who generated the JSON file used expression for that file, it wouldn't work.

@eballeste
Copy link

@aidanlister , you should be able to import it doing
import lottie from 'lottie-web/build/player/lottie_svg.min.js'
or
import lottie from 'lottie-web/build/player/lottie_light.min.js'

this is docs worthy

@matthew-dean
Copy link

@bodymovin

Regarding the lottie files themselves, if you consider they hold all the svg data and the animation data, they are usually smaller than coding them by hand.

I don't really agree, because coding them by hand would not have the overhead of Lottie / Lottie light. So it's not a 1:1 comparison. Lottie animations will almost always require more resources and size.

And it still beats a gif or video in file size.

Are there metrics that prove that? Also, it's probably easier to "load on demand" for video files, since Lottie assets end up being bundled in JS bundles, and most people do not use code splitting correctly. A video file, in contrast, is a small file which only gets downloaded when requested on a particular page, and can being playing before its fully loaded. So I wonder, in real-world usage, if Lottie ends up taking up more time to interactive.

@kopax-polyconseil
Copy link

kopax-polyconseil commented Aug 3, 2022

Hello, same here, lottie is the biggest lib in our node_modules, I just checked if there is a way to optimize that, and we found the min, I will have a try, but we use json lottie file, will it work with the min version? Otherwise, do we need all the lottie player ? we only use json anims.

image

Note: we use lottie-web through another module called react-native-web-lottie and we don't handle the import directly in our source code, see issue here, do you think it is possible to use the light version in here?

Edit: we can

image

umairkamilcodes added a commit to umairkamilcodes/static-assets-cloudflare that referenced this issue Jun 3, 2023
airbnb/lottie-web#1184
https://unpkg.com/lottie-web@5.2.0/build/player/lottie_light.min.js

Situation: Lottie JS Full Minified (i.e for Web, Android, etc) is blocking the main thread for 4s to 7s on average. This means that even though the HTML, CSS & Web JS have been parsed, other JS is still in progress. 

To the user, it looks like the blue loading bar is still active. This gives a bad impression.
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