title: When are MutationObserver callbacks fired?
body: <p>I know that MutationObservers callbacks may get called sometime after the DOM change. But the question is: What is the timing of these callbacks?
  Do the callbacks enter the event queue of the browsers? If so, when do they enter the queue?</p>
  
  <p>Are the callbacks:</p>
  
  <ul>
  <li>called immediately after the DOM mutation take place,</li>
  <li>called as soon as the function that manipulate DOM finishes,</li>
  <li>called as soon as the call stack is empty,</li>
  <li>enqueued immediately after the DOM mutation take place,</li>
  <li>enqueued as soon as the function that manipulate DOM finishes, or</li>
  <li>at some other time?</li>
  </ul>
  
  <p>For example, if the following piece of code is executed (with <a href="http://dbaron.org/log/20100309-faster-timeouts">setZeroTimeout defined here</a>):</p>
  
  <pre><code>var target = document.body;
  
  new MutationObserver(function(mutations) {
    console.log('MutationObserver');
  }).observe(target, {
    attributes: true,
    childList: true,
    characterData: true
  });
  
  
  // Post message
  setZeroTimeout(function () { console.log('message event'); });
  // DOM mutation
  target.setAttribute("data-test", "value");
  </code></pre>
  
  <p>Should "MutationObserver" be printed before "message event" or after it?
  Or is it implementation-defined?</p>
  
  <p>I'm getting "MutationObserver" before "message event" on Chromium 26, though the DOM mutation is after message posting. Maybe this is indicating that MutationObserver callbacks are <strong>not</strong> using the event queue.</p>
  
  <p>I have googled for HTML specification, DOM specification or browser implementation documents, but I didn't found anything related to this behavior.</p>
  
  <p>Any explanation or documentation on the timing of MutationObservers callbacks please?</p>