You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current LottiePlayer.svelte component uses bind:clientWidth and bind:clientHeight on lines 560-561.
In svelte, bind:clientWidth/Height attaches an empty iframe to monitor these properties of an element. However, attaching an empty iframe can cause significant slowdowns.
This use case of bind:clientWidth/Height isn't even justified, because the ONLY time where these variables are used is in the toggleZoom() function, which just reads them. There's no effects that could run when these properties change, it's unnecessarily slowing down the web page. Plus, we already have a wrapperRef which references the exact element these bindings are on.
Solution:
Get rid of the old variables.
Get rid the lines 560-561.
On the lines 485-486, use wrapperRef.clientHeight/Width.
The current
LottiePlayer.svelte
component usesbind:clientWidth
andbind:clientHeight
on lines 560-561.In svelte,
bind:clientWidth/Height
attaches an empty iframe to monitor these properties of an element. However, attaching an empty iframe can cause significant slowdowns.This use case of
bind:clientWidth/Height
isn't even justified, because the ONLY time where these variables are used is in thetoggleZoom()
function, which just reads them. There's no effects that could run when these properties change, it's unnecessarily slowing down the web page. Plus, we already have awrapperRef
which references the exact element these bindings are on.Solution:
Get rid of the old variables.
Get rid the lines 560-561.
On the lines 485-486, use
wrapperRef.clientHeight/Width
.Though I don't have the exact numbers, this will definitely speed up the component.
I'll create a pull request a little bit later.
The text was updated successfully, but these errors were encountered: