HTML5*享工作者和工作者之间有什么区别?

时间:2021-03-06 02:18:28

After reading this blog post: http://www.sitepoint.com/javascript-shared-web-workers-html5/

阅读此博客文章后:http://www.sitepoint.com/javascript-shared-web-workers-html5/

I don't get it. What's the difference between a Worker and a SharedWorker?

我不明白。 Worker和SharedWorker之间有什么区别?

4 个解决方案

#1


25  

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.

非常基本的区别:只能从创建它的脚本访问Worker,可以通过来自同一域的任何脚本访问SharedWorker。

#2


9  

SharedWorker's seem to have more functionality then Worker.

SharedWorker似乎比Worker更具功能。

Among that functionality is :

其中的功能是:

  • A shared global scope. All SharedWorker instances share a single global scope.
  • 共享的全球范围。所有SharedWorker实例共享一个全局范围。

W3C Spec:

W3C规格:

WHATWG Spec:

WHATWG规格:

#3


6  

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).

另一方面,专用工作者只是绑定到其主连接,并且不能将消息发布到其他脚本(工作者)。

#4


5  

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).

对于任何考虑使用SharedWorker的人 - Apple在2015年从WebKit中删除了对SharedWorker的支持。在他们当前的路线图中,没有重新实现的计划。 WebKit目前正在开发对Service Workers的支持,并提供类似的功能(参见此处进行比较)。

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

您可以在此处关注WebKit中ServiceWorkers的开发(也称为Safari支持)。

#1


25  

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.

非常基本的区别:只能从创建它的脚本访问Worker,可以通过来自同一域的任何脚本访问SharedWorker。

#2


9  

SharedWorker's seem to have more functionality then Worker.

SharedWorker似乎比Worker更具功能。

Among that functionality is :

其中的功能是:

  • A shared global scope. All SharedWorker instances share a single global scope.
  • 共享的全球范围。所有SharedWorker实例共享一个全局范围。

W3C Spec:

W3C规格:

WHATWG Spec:

WHATWG规格:

#3


6  

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).

另一方面,专用工作者只是绑定到其主连接,并且不能将消息发布到其他脚本(工作者)。

#4


5  

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).

对于任何考虑使用SharedWorker的人 - Apple在2015年从WebKit中删除了对SharedWorker的支持。在他们当前的路线图中,没有重新实现的计划。 WebKit目前正在开发对Service Workers的支持,并提供类似的功能(参见此处进行比较)。

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

您可以在此处关注WebKit中ServiceWorkers的开发(也称为Safari支持)。