Is there any performance gain or need to unleash the events of an element before deleting it?

Is there any performance gain or need to unleash the event (s) of an element before deleting it?

+3
source share
3 answers
+3
source

If the event was created using jQuery and the element is also deleted using jQuery, you do not need all the event handlers for this element, and all its child elements will also be removed by jQuery before deleting the element.

cm. .remove(), .empty(), .html()and .cleanData().

+2
source

Older versions of IE cannot garbage collect circular references between DOM nodes and JavaScript objects, because DOM nodes are only collected by reference counting. Therefore, programmers must manually break these links to avoid memory leaks.

Functions associated as an element property (such as events) always have a property thisthat points to the element, so they form a guaranteed circular reference.

+1
source

Source: https://habr.com/ru/post/1790221/


All Articles