[whatwg] Global Script proposal.

Dmitry Titov dimich at google.com
Wed Aug 19 10:48:12 PDT 2009


On Wed, Aug 19, 2009 at 7:37 AM, Patrick Mueller <pmuellr at muellerware.org>wrote:

> var context = new GlobalScript();  // perhaps 'webkitGlobalScript' as
>> experimental feature?
>> context.onload = function () {...}
>> context.onerror = function () {...}
>> context.load('foo.js');
>>
>
> Presumably this script is being loaded asynchronously, hence the callbacks.
>  But since the GlobalScript() constructor returns the "global" object,
> probably doesn't make sense to attach the handlers directly there, but
> actually on the load request somehow.


Good point. Alternative variant to construction/connection to this object
could be something like this:

window.createGlobalScript('name', 'foo.js', function(context) {..},
function(status) {..});

where the name and url pair play the same role as on SharedWorker, and 2
callbacks: one delivers load status/errors, another comes with resolved
context when it's ready. One benefit of this is that 'context' does not have
to expose the 'external' API on it and it is always functional once it's
returned. The syntax in the proposal was motivated by commonality with other
APIs, like XHR or window.open - however I agree this doesn't fit 100% either
of them...

I guess I'm wondering if there will be some desire to have pages opt-in to
> this support, signaling this through an additional API, or like the
> app-cache's manifest attribute on the <html> element, something in the DOM;
> doesn't seem like we should drag the DOM in here, just mentioned it because
> I was reminded of the way the opt-in works there.
>

It is a good idea indeed to have some sort of static opt-in information,
maybe via a feature of app-cache - which could hint the UA to load
participating pages (of the same application) into the same process so they
could share Global Script. It is still impossible (and probably not
important) to guarantee a singularity of the Global Script (as in case of
cross-domain iframes) but it'd be a good optimization for a multi-process
UA.

Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090819/345423ef/attachment-0002.htm>


More information about the whatwg mailing list