title: jQuery beforeClose empties a dialog much faster than close - why?
body: <p>Suppose I create a dialog with jQuery (if relevant - 1.7.1). The dialog opens a div (let's name it "divToEmpty") that can contain thousands of text divs inside of it. Suppose further that I want to empty the aforementioned div on dialog close.</p>
  
  <p>There are 2 options:</p>
  
  <pre><code>// options 1
  
  $('#divToEmpty').dialog({
      beforeClose: function() {
          $('#divToEmpty').html('');
      }
  });
  
  // option 2
  
  $('#divToEmpty').dialog({
      close: function() {
          $('#divToEmpty').html('');
      }
  });
  </code></pre>
  
  <p>Option 1 is much, much faster than option 2 (which crashes jQuery script on large enough quantity of inside divs).</p>
  
  <p>Why?</p>
  
  <p>My conjecture is that some infinite loop gets created when resetting a closing dialog (cascades of DOM and style changes or something like that), which is avoided is you reset the div first and then close the dialog. But this idea is funky in itself...</p>