title: JavaScript: event listener when rendering update is done
body: <p>I'm developing an Android application and the scenario is:</p>
  
  <ol>
  <li>There is a webview with static html code in the background, and a splash imageview (company logo) that covers the webview which is not ready yet.</li>
  <li>window.onload in the initial html code initiates a websocket connection to the server to retrieve some dynamic html code.</li>
  <li>The html document is updated with innerHTML (or DOMParser) according to the retrieved dynamic html code.</li>
  <li>When the update and rendering is complete, JavaScript code makes a call to a Java stub function (java.didLoad), to remove the splash imageview in the foreground to reveal the all ready webview.</li>
  </ol>
  
  <p>When there is only static html code this is easy because window.onload is exactly what I need. It is called only after everything is ready and completely rendered. The problem is, I can't find an event listener that works exactly the same way as window.onload when the page is updated dynamically. If I call java.didLoad right after the innerHTML call, the rendering update is not done yet so I can see flickering of the webview contents. It make no difference if I do so in img.onload of an image element included in the retrieved html code, it is called before rendering and the webview is revealed prematurely. Same with window.requestAnimationFrame. The only approach worked was setTimeout with some time interval, but that is ad-hoc and I really want to avoid it.</p>
  
  <hr>
  
  <p><strong>TL;DR</strong> Long story short, after updating an html page with innerHTML or DOM manipulation, is there an event listener function which is called after everything is set and rendering is complete?</p>
  
  <p>I know there have been some similar (not same) questions before, but none of the answers I tried worked.</p>