Web Workers

Jump to: navigation, search

Web Workers Use Cases and Requirements

Use cases

The overall use case is more powerful Web applications. In particular:

  • Sharing a core "engine" for a Web application between multiple open windows of that application.
  • Performing time-consuming tasks using synchronous and uninterrupted coding paradigm.
  • Separating application logic from user interface logic.


This specification aims to address the following requirements:

  • Background workers: A Web application needs to keep its data synchronised with the server, both sending updates to the server and receiving updates from the server, including handling buffering of updates for when the application goes offline. The code to do this would ideally be independent of the UI code.
  • URLs: Workers should be spawned from URLs, not from strings, since script rarely has access to its own source.
  • Message queuing: Messages sent to a worker before the worker has initialised should not be lost.
  • Workers should have access to timers.
  • Workers should have access to the network.
  • Workers should be able to use libraries.
  • Implementations should not have to expose Node or Document objects to workers.
  • Workers should not share anything with the outside world. The objects representing the worker in the worker itself and in the context that created the worker should be different, for instance.
  • Shared workers: Multiple instances of the same Web application would want to keep just one connection back to the server.
  • Capabilities granting: It should be possible for code running in one iframe to negotiate a connection to another iframe, with that connection granting certain rights (e.g. adding to an address book but not reading from it).
  • Delegation: It should be possible for one worker to spawn another worker and efficiently delagate a request to that worker, without the caller being aware of the delagate and without the original worker having to proxy all the messages.
  • Workers whose parents are not longer useful should be killed. Workers should be able to detect this is about to happen and exit gracefully.