title: Get height of div after content change in vanilla javascript
body: <p>How can I get the new height of div after the content of the div changes? Using JQuery, this is easy, but I am having problems with this in vanilla javascript. </p>
  
  <p>I tried to attach an event listener to the div, but it never gets triggered. </p>
  
  <pre><code>document.getElementById('test').addEventListener('DOMContentLoaded', function() {
        console.log(document.getElementById('cookies-popup').getBoundingClientRect().height);
      });
  </code></pre>
  
  <p>The content of the div is dynamically changed after retrieved from the server. I tried to get the height with a callback after the http request is done, but the element.offsetHeight or the above command still return the old height when the div has no content inside.</p>
  
  <p>The code that changes the content of the div: </p>
  
  <pre><code>this.staticPageService.getData('test').subscribe(payload =&gt; {
      this.divContent = payload.content;
  });
  </code></pre>
  
  <p>Any ideas? </p>
  
  <p>Thanks</p>