title: Use of dummy and empty jQuery promises
body: <p>I run multiple animations and perform some action when they're complete, using jQuery <code>promises</code>:</p>
  
  <pre><code>$.when(foo(),  
         bar(),  
         baz())  
   .done(allDone);  
  </code></pre>
  
  <p>Each function (<code>foo</code>, etc.) returns a <code>jQuery.Promise()</code>.</p>
  
  <p>Now say I want to include a function which doesn't animate anything, but its timing is related to the animations - I can't include it in the chain, as it doesn't return a promise.</p>
  
  <p>So I can hack it like so:</p>
  
  <pre><code>function qux() {
    if (something) {
      return $(".whatever")
        .removeClass("bob")
        .addClass("fred")
        .append(/*...do stuff...*/)
        .animate({ left: "+=0" }, 0, callback ) // &lt;-- dummy animation does nothing
        .promise();                             // &lt;-- this is a dummy promise
    }
    else {
      return $().promise();                     // &lt;-- this is an "empty" promise
    }
  }
  </code></pre>
  
  <p>And now I can chain it:</p>
  
  <pre><code>$.when(foo(),  
         bar(),  
         baz(),
         qux())  
   .done(allDone);  
  </code></pre>
  
  <p><em>This works.</em> But I'm bending the rules here - are there any gotchas I haven't taken into account, or am I somehow stomping on the fx queue?</p>
  
  <p><strong>UPDATE</strong><br>
  As per answers below, the <code>qux()</code> function can be rewritten as:</p>
  
  <pre><code>function qux() {
    if (something) {
      $(".whatever")
        .removeClass("bob")
        .addClass("fred")
        .append(/*...do stuff...*/);
    }
  }
  </code></pre>