get data from php server before document load
<p>in order to recover data from server I use XMLHttpRequest and my code is this (it works fine)</p>

<pre><code>window.onload = function getArtists() {
    xmlhttpLoad=new XMLHttpRequest();           
    xmlhttpLoad.onreadystatechange=function() {
        if (xmlhttpLoad.readyState==4 &amp;&amp; xmlhttpLoad.status==200) {
            // put data in an invisible HTML elem           
        }
    }
}
</code></pre>

<p>Now I want to use a particular library, but it requires that this data are loaded BEFORE document document.onload is fired. How can I do this? Can I use the code above but block HTML parsing until data are loaded? I mean something like</p>

<pre><code>&lt;head&gt;
    &lt;script&gt;
        // block parsing until data are loaded
        // put data from server in a variable
    &lt;/script&gt;
    &lt;script src="newLib.js"&gt;&lt;/script&gt;
&lt;head&gt;
</code></pre>
