title: Dojo addOnLoad, but is Dojo loaded?
body: <p>I've encountered what seems like a chicken &amp; egg problem, and have what I think is a logical solution.  However, it occurred to me that others must have encountered something similar, so I figured I'd float it out there for the masses.</p>
  
  <p>The situation is that I want to use dojo's addOnLoad function to queue up a number of callbacks which should be executed after the DOM has completed rendering on the client side.  So what I'm doing is as follows:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script type="text/javascript" src="dojo.xd.js"&gt;&lt;/script&gt;
          ...
      &lt;/head&gt;
      &lt;body&gt;
          ...
          &lt;script type="text/javascript"&gt;
              dojo.addOnLoad( ... );
              dojo.addOnLoad( ... );
              ...
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now, the issue is that I seem to be calling dojo.addOnLoad before the entire Dojo library has been downloaded the browser.  This makes sense in a way, because the inline SCRIPT contents should be executed <em>before</em> the entire DOM is loaded (and the normal body onload callback is triggered).</p>
  
  <p>My question is this - is my approach sound, or would it make more sense to register a normal/standard body onload JavaScript callback to call a function, which does the same work that each of the dojo.addOnLoads is doing in the SCRIPT block.  Of course, this begs the question, why would you ever then use dojo.addOnLoad if you're not guaranteed that the Dojo library will be loaded prior to using the library?</p>
  
  <p>Hopefully this situation makes sense to someone other than me.  Seems like someone else may have encountered this situation.</p>
  
  <p>Thoughts?</p>
  
  <p>Best Regards,
  Adam Rice</p>