What's the difference between Shared Worker and Worker in HTML5?

半腔热情 提交于 2019-11-28 04:18:17

Very basic distinction: a Worker can only be accessed from the script that created it, a SharedWorker can be accessed by any script that comes from the same domain.

SharedWorker's seem to have more functionality then Worker.

Among that functionality is :

  • A shared global scope. All SharedWorker instances share a single global scope.

W3C Spec:

WHATWG Spec:

A shared worker can work with multiple connections. It posts messages to ports to allow communication between various scripts.

A dedicated worker on the other hand is simply tied to its main connection and cannot post messages to other scripts (workers).

Martijn van Halen

To anyone considering using SharedWorker -- Apple removed support of SharedWorker from WebKit in 2015. In their current roadmap there is no plan for reimplementation. Support for Service Workers is currently under development for WebKit and offer similar capabilities (see here for comparisons).

You can follow the development (aka Safari support) of ServiceWorkers in WebKit here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!