Waiting for a script object to load
<p>I'm trying to create a jquery script that will be run from the console of google chrome and will analyze a page.
My problem is that when I run the following code:</p>

<pre><code>var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
alert($('a'));
</code></pre>

<p>I get a message box with null (bad result)
But if I separate it to to executions like this:</p>

<p>step1:</p>

<pre><code>var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
</code></pre>

<p>step2:</p>

<pre><code>alert($('a'));
</code></pre>

<p>It works great and I get [object] that is my desired result.</p>

<p>The question is what can I do to run this in a single batch?</p>
