[webkit-dev] GlobalScript API.

Patrick Mueller pmuellr at muellerware.org
Tue Sep 1 20:52:13 PDT 2009

Dmitry Titov wrote:
> Thanks a lot Maciej!
> As a note to the API described in this thread: there was a proposal in
> private thread to replace the JS constructor with 4 parameters with a tag:
> instead of
> var globalScript = new webkitGlobalScript(name, url, loadHandler,
> errorHandler);
> to have this:
> <webkit-globalscript name='...', src='url', onload=...
> onerror=...></webkit-globalscript>

My initial reaction is ... urghhh ...

> The first tag with a specific name that provides a src or inline script or
> injected with innerText would effectively supply 'initial script'. The
> later-encountered tags withthe same name would have their initial script
> ignored and simply connected to the same one. The tag's DOM element would be
> EventTarget (for load and error) and have a 'context' property to pull the
> global scope object of the script.

The element is much less flexible than JavaScript APIs.  For instance, I 
can imagine I may want to conditionally use a global script.  If we only 
had the element, I'd have to construct one in JS, then inject it into 
the DOM.  Calling a constructor would be a lot less work.  :-)

Patrick Mueller - http://muellerware.org

More information about the webkit-dev mailing list