<div>I did mention 2 forms of script load indeed, mostly trying to find a simplest form that will be also consistent with what's already there in the spec.</div><div><br></div><div>In terms of loading scripts, it seems the GlobalScript is quite similar to what SharedWorker does to load its scripts.When creating SharedWorker, one specifies the url right away as a constructor parameter, and this url later is used to form an ID of the SharedWorker. The load is asynchronous and the page is registering an event handler to 'hear' from the script when it is ready. The Worker can, in turn, create 'nested' Workers (async). Also, it can load more scripts into themselves via importScript(urls) - this time synchronously (this is rough equivalent of <script> tag in a JS context). Note that initial load is different from 'importing' more script - initial loading is governed by SOP and is async, while the importScript can go cross-domain, does not create a security context and is synchronous. </div>
<div><br></div><div>Whether or not this is the best possible scheme is a separate topic, but it seems close enough to what GlobalScript needs so if nothing else, consistency with this spec might be a good idea.</div><div>
<br></div><div>Dmitry</div><div><br><div class="gmail_quote">On Mon, Aug 24, 2009 at 6:05 AM, Patrick Mueller <span dir="ltr"><<a href="mailto:pmuellr@muellerware.org" target="_blank">pmuellr@muellerware.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div>Patrick Mueller wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Michael Nordman wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm confused about the manual loading of the script into the context? The<br>
original proposal called for providing a script url when creating/connecting<br>
to an instance of a global-script... in which case each client page<br>
expresses something more like...<br>
globalScript = new GlobalScript(scriptUrl);<br>
globalScript.onload = myFunctionThatGetsCalledWhenTheScriptIsLoaded;<br>
// some time later onload fires, if the script was already loaded, its<br>
called on the next time thru the message loop<br>
</blockquote>
<br>
Here's what Dmitry Titov proposed on 2009/08/17:<br>
<br>
var context = new GlobalScript();<br>
context.onload = function () {...}<br>
context.onerror = function () {...}<br>
context.load('foo.js');<br>
</blockquote>
<br></div></div>
Dmitry had a later note which combined creation of the context and loading of the script. But I suspect one thing people will want to do, in development anyway, is load multiple scripts into a context - like you can in workers. Which would mean we'd still need a function to load a script, or the only way to load a script would be by also creating a new context - which is much like the serverJS module concept.<div>
<div></div><div><br>
<br>
-- <br>
Patrick Mueller - <a href="http://muellerware.org" target="_blank">http://muellerware.org</a><br>
<br>
</div></div></blockquote></div><br></div>