Currently, we subscribe to the browser events click, keyup, scroll, and resize every time the mediumZoom function is called, which also happens during clone. Instead of always being subscribed to these events, it is much better to subscribe only when necessary. These events stack up on each other, significantly affecting performance and preventing the browser from garbage collecting. This is especially important in SPA applications when we use a component-based approach.
Result
No performance degradation when images are missing or not active.
Summary
Currently, we subscribe to the browser events
click
,keyup
,scroll
, andresize
every time themediumZoom
function is called, which also happens duringclone
. Instead of always being subscribed to these events, it is much better to subscribe only when necessary. These events stack up on each other, significantly affecting performance and preventing the browser from garbage collecting. This is especially important in SPA applications when we use a component-based approach.Result
No performance degradation when images are missing or not active.