title: While variable is not defined - wait
body: <p>I have a <code>click</code> event that is triggered from another place automatically for the first time. My problem is that it runs too soon, since the required variables are still being defined by Flash and web services. So right now I have:</p>
  
  <pre><code>(function ($) {
      $(window).load(function(){
          setTimeout(function(){
              $('a.play').trigger("click");
          }, 5000);
      });
  })(jQuery);
  </code></pre>
  
  <p>The problem is that 5 seconds for a person with a slow internet connection could be too fast and vice versa, for a person with a fast internet connection, it's too slow.</p>
  
  <p>So how should I do the delay or timeout until <code>someVariable</code> is defined?</p>