tjenkinson/dynamic-marquee

Question: loop same element with long activity, DOM slowdown?

Closed this issue · 2 comments

Hey,

in the loop section, theres this sentence:

When returning DOM elements each function should build the element from scratch, as the same DOM element is not allowed to appear on the marquee multiple times.

As far as I understand, it can cause issues for long activity apps, because creating DOM elements 1 million times over a perioud of X hours will slowdown the DOM renderer (browser), no?
Is there a way to have only the maximum needed elements, or set a maximum and if overseeded, re-use older elements already in the DOM?

Or does the engine take care of it themselves?

Thanks!

Hey @pquerner !

The marquee appends the element before it appears on screen and also removes it from the dom after it has left. I think the performance concern is if you have too many elements in the dom, which isn't the case here.

Also once the element is removed from the dom providing you don't keep a reference to the element you return it will be garbage collected so shouldn't cause a memory leak either.

Thanks for getting back to me. It wasnt clear to me that the DOM is automatically cleared. Thanks for confirming it. :)