January 2018
Intermediate to advanced
332 pages
7h 36m
English
It's imperative that we keep our DOM references to a minimum, so a well-known step that we like to perform is caching the DOM elements in our JavaScript so that we do not have to query any of the DOM elements over and over. However, once the DOM elements are removed, we will need to make sure that these methods are removed from our cache as well, otherwise, they will never get GC'd:
var cache = { row: document.getElementById('row')};function removeTable() { document.body.removeChild(document.getElementById('row'));}
The code shown previously removes the row from the DOM but the variable cache still refers to the DOM element, hence preventing it from being garbage collected. Another interesting thing to ...
Read now
Unlock full access