I'm trying to get my head around - why is the DOM Nodes keeps on going up when I'm checking my website in the Performance Monitor.
I've added this simple code that just looping on:
1) adding and element to a wrap, 2) bind it with a click event. 3) removing it.
but still the DOM Nodes are always up the I check the performance. any thoughts?
<!DOCTYPE html>
<html>
<head>
    
    <title></title>
    <style>
        .wrap{
            font-size:50px;
        }
    </style>
</head>
<body >
    <div class="wrap">
        <div></div>
    </div>
    
   <script>
       var counter = 0;
       setInterval(function () {
           //increase counter (for display) 
           counter++;
           //get wrap 
           var wrap = document.getElementsByClassName("wrap")[0];
           //remove its children
           while (wrap.firstChild) {
               wrap.firstChild.removeEventListener("click", onclick);
               wrap.removeChild(wrap.firstChild);
           }
           //create new element 
           var div = document.createElement("div");        // create a div element
           div.innerHTML = 'hello mosh (' + counter + ')';
           
           //bind events
           div.addEventListener("click", onclick);
           // append the div to wrap
           wrap.appendChild(div);                                
       }, 200);
       //on click function
       var onclick = function () { alert('click'); }
   </script>
</body>
</html>


