title: Javascript appendChild callback?
body: <p>I need to add an HTML5 video to a page with the following code:</p>
  
  <pre><code>document.querySelector("#mydiv").appendChild(video);
  console.debug(document.querySelector("video").clientWidth);
  </code></pre>
  
  <p>My problem is, the second line returns 0 because it takes a while for the <code>video</code> tag to load the video it's going to play. If I manually type the second line in the console once the page is loaded, I get the actual value. Is there a better way to get this value than using timeouts to periodically check if the value's been updated?</p>