title: Methods for troubleshooting "A script on this page is causing IE to run slowly" caused by AJAX?
body: <p>I have a page in my application that refreshes some content (a list of users currently signed in) from the server every 10 seconds. This data is loaded using the <a href="http://docs111.mootools.net/Remote/Ajax.js" rel="nofollow noreferrer">Ajax</a> class from the <a href="http://docs111.mootools.net/" rel="nofollow noreferrer">mootools framework</a>, specifically with Javascript that looks like:</p>
  
  <pre><code>var xmldata = (function() {
      new Ajax('xmldata.jsp?time='+$time(), {method: 'get', onComplete: dataLoaded, autoCancel: true}).request();
  }).periodical(10000);
  </code></pre>
  
  <p>(which, every 10 seconds, creates an <code>Ajax</code> object and calls it's <code>request()</code> method, which will invoke <code>dataLoaded()</code> method when complete).</p>
  
  <p>If a user leaves their browser window open to this page for about 45-60 minutes, then attempting to navigate elsewhere will cause IE (v7 for sure, v6 as well I believe, Firefox or Chrome do not have this issue) to display the following popup:</p>
  
  <blockquote>
    <p>Stop running this script?<br>
    A script on this page is causing Internet Explorer to run slowly.
    If it continues to run, your computer may become unresponsive.</p>
  </blockquote>
  
  <p>Now, it seems to me that this is likely caused by some sort of leak in the underlying script in the mootools framework - either too many <code>Ajax.request()</code> calls are queuing up to be called or some objects are not being properly cleaned up, even though the framework is supposed to have some garbage collection features in it.</p>
  
  <p>What are the best ways to analyze what IE's Javascript engine has done under the covers? Is there any possible way to determine if either of my hypothesis' are correct?</p>
  
  <p>I've seen that in <a href="https://stackoverflow.com/questions/212550/a-script-on-this-page-is-causing-ie-to-run-slowly">a similar question</a>, <a href="https://stackoverflow.com/questions/212550/a-script-on-this-page-is-causing-ie-to-run-slowly#214244">someone suggested</a> using IBM Page Profiler to debug this issue. I've tried using Page Profiler and haven't had much success - it seems to be useful if you are having a problem with the initial load of a page (to analyze what component is causing an excessive loading delay) but it does not seem to be able to analyze what goes on with Javascript running within a page <em>after</em> it has been completely loaded. I see in Page Profiler that the async calls to xmldata.jsp are requested every 10 seconds, but Page Profiler only shows that the server responds ok (in about 600 ms) but has no insight into how the parent page's script uses this data.</p>
  
  <p>In addition, <a href="http://n2.nabble.com/IE.-Stop-running-this-script-popup-error---mootools-1.11-td1572531.html" rel="nofollow noreferrer">in this post</a> on the since-closed mootools discussion list, someone suggests removing code that registers an <code>unload</code> listener to call a garbage-collection method to resolve this issue - but that seems like resolving a symptom of the problem and not the problem itself.</p>