2017-03-17 32 views
0

私は共有ワーカーの例を見なければなりませんでした。しかし、私は労働者と共有労働者の違いを特定することはできません。 共有ワーカーの例https://github.com/mdn/simple-shared-worker。 誰でも説明できますか?共有ワーカーとは何ですか?ワーカーと共有ワーカーの違いは?

+0

私は既にそれを見ました。しかし、私の質問は異なっています。私の疑念は、賢明ではなく賢明な例です。共有ワーカーが同じドメインのすべてのスクリプトにアクセスする方法 – Vasi

+0

こんにちは、私の質問は重複していますが、答えは異なります。フロントエンドの開発者として、私はこの答えを知っています。しかし、スタックオーバーフローからのあなたの提案、リンクを理解できません。あなたのリンクは非常に基本的な情報を持っています。だから私は多くのリンクを答えを参照してください。回答タブの私の答えを見て、それを理解してください。あなたが自分自身を理解できない場合は、このコメントで私に連絡してください。 – Vasi

答えて

-1

ワーカーとSharedWorkerの作業フローを以下に示します。

This image helps to understand working flow and common behavior of Worker and SharedWorker

Difference between Worker and SharedWorker

ワーカーと共有ワーカー間の同様の特徴。

The Worker works in another thread. So it's not affecting the main thread. So that time users can scroll, view the page without blocking. 

1. Worker can't access DOM elements from the web page. 
2. Worker can't access global variables and functions from the web page. 
3. Worker can't call alert() function. 
4. Objects such as window, parent, document can't be accessed inside the worker. 

労働者自身の機能。

Workers life time between page creates and closure. Once the page creates the new workers will be created. View first image that blog diagram says about Wokers. 

共有ワーカー自身の機能。

共有ワーカーは、同じドメインのすべてのWebページを接続します。ブログの図がWokers vs Shared Workersについて述べた第2の画像を見る。

参照リンクWorkers document

関連する問題