title: How to detect resize of any element in HTML5
body: <p>What should the best practices to listen on element resize event?</p>
  
  <p>I want to re-position an element (jQuery dialog in my case), once it's size changed. But I am now more interested to do in a general way to to listen to resize event, unaware of how the resize happens. It suppose to be simple until I found an element can be re-sized by</p>
  
  <ul>
  <li>window resize</li>
  <li>content text changes</li>
  <li>children elements or their children elements resized</li>
  <li>a sibling element resize (e.g. a cell in a table)</li>
  <li>JavaScript changes it src(of img)/style attribute directly (or it's child's)</li>
  <li>JavaScript rewrite CSS rules or stylesheet</li>
  <li>native resize feature textarea or <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/resize">CSS3 resize</a></li>
  <li>browser's zoom or text-enlarge</li>
  <li>CSS transition or animations (by :hover or any other mean)</li>
  </ul>
  
  <p>In the de-facto standard, there is a event <code>window.onresize</code> to subscribe resize on a window/frame.
  But there is no a standard event on the HTML content or DOM Elements.</p>
  
  <p>I come across the following thought</p>
  
  <ul>
  <li><a href="https://www.w3.org/TR/DOM-Level-3-Events/">DOM Level 3</a> event target only on window/document type</li>
  <li>IE has <a href="https://msdn.microsoft.com/en-us/library/ie/ms536959(v=vs.85).aspx">onresize</a> for Elements but it is IE only implementation</li>
  <li><a href="https://www.w3.org/TR/dom/#mutation-observers">MutationObserver</a> which replace <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Mutation_events">Mutation Events</a>, but it does not fit the need of "onresize"</li>
  <li>naive JavaScript polling</li>
  </ul>
  
  <p>MutationObserver is close(inner DOM changes), but it does not (yet) cross browser (IE10 does not support) and it generate noise, not CSS aware.</p>
  
  <p>A naive JavaScript polling should work in all case, but it generate either delay or CPU waste of many poll.</p>