> 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lochiwei.gitbook.io/web/browser/api/worker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
