Lottie-web: Picture loaded twice in lottie-web

Created on 19 Oct 2018  路  7Comments  路  Source: airbnb/lottie-web

I change the pictures in json file from base64 to cdn url, then strange things happened: all the pictures load twice.

image

Most helpful comment

Yes, it's normal that it loads twice using the svg renderer.
One is triggered by the preloader before the elements are added to the DOM.
The second is loaded by the ImageElement when it adds the tag to the
It's an intended behavior so every element is ready and cached before starting the animation.

All 7 comments

Hi, how are you changing them?

I edit the content manually.

lottie preloads images before starting the animation.
But I'm not sure if this is the reason why you see the image loaded twice.
Can you share some more info or a link?

Here is an example https://codepen.io/wrbing/pen/VEzYBd
You can see the image request twice like this:
image

Yes, it's normal that it loads twice using the svg renderer.
One is triggered by the preloader before the elements are added to the DOM.
The second is loaded by the ImageElement when it adds the tag to the
It's an intended behavior so every element is ready and cached before starting the animation.

Yes, it's normal that it loads twice using the svg renderer.
One is triggered by the preloader before the elements are added to the DOM.
The second is loaded by the ImageElement when it adds the tag to the
It's an intended behavior so every element is ready and cached before starting the animation.

In Android webview load a html page . when lottie-web preload a image , it may just load a half and then turn fail, in this circumstance, android device will cache the broken image(it just load a half).

in the second time load image (code: this.innerElem.setAttributeNS('http://www.w3.org/1999/xlink','href',assetPath);) it will load the braken cached image. how could i disable preload

Bringing this back - this causes extra problems when using elements like sliders, which need to make copies of the containing components to allow for infinite scrolling. This could mean assets being loaded up to six times (!!) instead of the two described here.

How might one disable preloading so the image is only loaded once, and then cached properly by the browser?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cpdt picture cpdt  路  4Comments

joelponce picture joelponce  路  4Comments

zhengs picture zhengs  路  3Comments

samiam2017 picture samiam2017  路  3Comments

leantide picture leantide  路  3Comments