> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/browser/api/worker.md).

# web worker

[JS](/web/js.md) ⟩ [browser](/web/browser.md) ⟩ [web API](/web/browser/api.md) ⟩ web worker

{% hint style="success" %}
(a JS [environment](/web/js/concept/env.md)) an <mark style="color:yellow;">**extension**</mark> on top of [browser](/web/browser.md)-JS behavior, which allows a <mark style="color:yellow;">**JS file**</mark> to run in a completely <mark style="color:yellow;">**separate thread**</mark> from the thread that's running the main JS program.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %} <mark style="color:purple;">**Web Worker**</mark> code&#x20;

* <mark style="color:red;">**does not**</mark> have <mark style="color:yellow;">**access**</mark> to the [DOM](/web/browser/dom.md). (<mark style="color:red;">**can't**</mark> access [window](/web/js/scope/global/object/window.md), for example)
* <mark style="color:red;">**does not**</mark> <mark style="color:yellow;">**share**</mark> the [global scope](/web/js/scope/global.md) with the <mark style="color:yellow;">**main JS program**</mark>.
  {% endhint %}

{% hint style="success" %} <mark style="color:purple;">**Web Worker**</mark> code <mark style="color:green;">**do**</mark> have access to the following [web API](/web/browser/api.md)：

* naviagtor
  {% endhint %}
  {% endtab %}

{% tab title="👥 相關" %}

* <mark style="color:purple;">**web worker**</mark> is a JS [environment](/web/js/concept/env.md).
  {% endtab %}

{% tab title="📗 參考" %}

* [ ] [YDKJS: Scope & Closures (v.2)](/web/master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2.md) ⟩ Ch. 4 ⟩ [Web Worker](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch4.md#web-workers)
* [ ] MakeUseOf ⟩ [An Introduction to JavaScript Web Workers](https://www.makeuseof.com/javascript-web-workers-introduction/)
  {% endtab %}

{% tab title="📘 手冊" %}

* [ ] [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) ⟩ [Worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker)
  {% endtab %}

{% tab title="🚧" %}

* [ ] navigator
  {% endtab %}
  {% endtabs %}
