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
Not really. Even if I remove the getElementsByClassName some kind of DOM marker (attribute i.e.: data-lazyload) should always be used otherwise I could produce memory leaks. (We currently can not create weak references in JS...)
I'm getting the DomNode so in my case its not necassery that lazysizes parse the dom to get the elements so I just want to avoid that. My idea was implementing something like this:
@alexander-schranz
Yes, this would create a hard reference with the potential of leaking dom nodes. . Additionally it would be very different to the normal way so that it would add a lot of code.
Again, what is the problem with the DOM API(s):
DOMNode.classList.add('lazyload');//or maybe also possible in the future://DOMNode.setAttribute('data-lazyload', '');
As told I have the element in JS. In this case I want to avoid to manipulate the DOM and throw a rerender.
About the hard reference I would say that a removeElement method could be added.
But I understand you when it will add a lot of code that you cant change the current behaviour.
Just to understand it how you handle it currently are you calling getElementsByClassName on every resize/scroll to not keep the nodes in the memory?
@aFarkas thanks for the create explanation didn't know about live nodelist (learned something new 😄 ) and thanks for the change. Will try using the lazySizes.elements.
Activity
aFarkas commentedon Jun 8, 2017
Not really. Even if I remove the
getElementsByClassName
some kind of DOM marker (attribute i.e.:data-lazyload
) should always be used otherwise I could produce memory leaks. (We currently can not create weak references in JS...)What is wrong with this?:
alexander-schranz commentedon Jun 8, 2017
I'm getting the DomNode so in my case its not necassery that lazysizes parse the dom to get the elements so I just want to avoid that. My idea was implementing something like this:
aFarkas commentedon Jun 8, 2017
@alexander-schranz
Yes, this would create a hard reference with the potential of leaking dom nodes. . Additionally it would be very different to the normal way so that it would add a lot of code.
Again, what is the problem with the DOM API(s):
alexander-schranz commentedon Jun 11, 2017
As told I have the element in JS. In this case I want to avoid to manipulate the DOM and throw a rerender.
About the hard reference I would say that a removeElement method could be added.
But I understand you when it will add a lot of code that you cant change the current behaviour.
Just to understand it how you handle it currently are you calling
getElementsByClassName
on every resize/scroll to not keep the nodes in the memory?expose lazySizes elements (fixes #399)
aFarkas commentedon Jun 13, 2017
Produces a live nodelist you don't need to call it.
If you use
lazySizes.rAF
/requestAnimationFrame
you shouldn't add any noticeable workload to the browser. (I would call it premature optimization.)I just exposed
lazySizes.elements
, if you overwrite it by adding a getter, you can implement your own logic.But you have to handle the full remove logic and add logic yourself.
alexander-schranz commentedon Jun 13, 2017
@aFarkas thanks for the create explanation didn't know about live nodelist (learned something new 😄 ) and thanks for the change. Will try using the
lazySizes.elements
.