[whatwg] Feedback on Web Worker specification
fredandw at live.com
Wed Nov 21 15:45:14 PST 2012
Thank you for the suggestion. Using the <script> element seems like a good
approach to explore.
Overloading the 'type' attribute could be problematic because the script type
may well be orthogonal to the JS context to which the script applies. Could I
suggest a new attribute, for example 'context' that declares the script context.
I presume allowing multiple script elements to declare code for a single worker
would be a complex a thread synchronization problem and thus might be best
If so then using the element id seems ok. Otherwise perhaps giving the workers
a name would be better so that multiple script elements could declare code for
a particular worker? Or could the 'class' attribute suit?
If the starting of the worker could be deferred until the page had all loaded then
perhaps the above usage could be thread safe.
I presume allowing the document JS to inject new script elements for a worker
would also be a complex thread synchronization problem and might also be best
For the use case I have in mind the worker needs to be created from only static
markup so such a restriction would suit.
Supporting the 'src' attribute would also be useful, particularly for pages using a CSP.
> From: esprehn at chromium.org
> Date: Tue, 20 Nov 2012 23:49:00 -0500
> To: ian at hixie.ch
> CC: whatwg at whatwg.org
> Subject: Re: [whatwg] Feedback on Web Worker specification
> On Tue, Nov 20, 2012 at 6:30 PM, Ian Hickson <ian at hixie.ch> wrote:
> > ...
> > On Sat, 3 Nov 2012, Fred Andrews wrote:
> > >
> > > Feedback and suggestions for appropriate markup to declare web workers
> > > would be appreciated.
> > Workers are only usable from script, so just start them in script. No need
> > for anything declarative.
> This has come up a couple times with developers and I think being able to
> <script type="worker" id="taskQueue">
> and then being able to access the worker to post message it by id would be
> extremely useful.
> Forcing the code into a separate file or requiring a data URL is annoying.
> - E
More information about the whatwg