Removing DOM nodes in JavaScript to save memory

I use the Safari browser to view my web page, which is rich in Javascript. I see that Safari takes up a lot of memory (500-900 MB) when browsing a web page and performing various operations. I want to know if I need to delete DOM objects using, for example var elem = document.getElementById('Id1');, to optimize the use of this memory? If any other pointers please suggest. Also, how can we remove this DOM object in the easiest way?

Thanks Siddhart

+3
source share
3 answers

One point of clarification. Your sample code does not create a DOM node; it just extracts a link to an existing node:

var elem = document.getElementById('Id1');

, :

elem.parentNode.removeChild(elem);
+1

DOM , ( ).

, DOM javascript ( , DOM JS Garbage Collectors).

:

+1

webkit . , Safari, Chrome.

/.

This is a good tutorial on using the Safari Inspector utility.

0
source

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


All Articles