> For the complete documentation index, see [llms.txt](https://rumblekat.gitbook.io/weekendstudy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rumblekat.gitbook.io/weekendstudy/webworker-serviceworker.md).

# WebWorker와 ServiceWorker

2021.03.27 스터디 내용

## Web Worker란?

&#x20;웹 워커는 스크립트 연산을 웹 어플리케이션의 주 실행 스레드와 분리된 별도의 백그라운드 스레드에서 실행할 수 있는 기술. 웹 워커를 통해 무거운 작업을 분리된 스레드에서 처리하면, 주 스레드가 멈추거나 느려지지 않고 동작할 수 있다.  [WebWorker](https://developer.mozilla.org/ko/docs/Web/API/Web_Workers_API) [ServiceWorker](https://developers.google.com/web/fundamentals/primers/service-workers)&#x20;

## Web Worker의 단점

1. 워커에서 DOM을 직접 조작할 수 없고, Window의 일부 메서드와 속성은 사용 불가. 그러나 [웹소캣](/weekendstudy/websocket.md) [IndexedDB](/weekendstudy/indexeddb.md) 를 포함한 많은 수의 항목도 사용 가능

![WebWorker에서 사용가능한 함수](https://562176879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWPDjQKWN2FDFXk5rj8%2F-MWPFwL9rsYdw2zLT9qJ%2F-MWPGHIK3VMCwnYN4K35%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-03-22%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%2011.09.36.png?alt=media\&token=ccd85a77-fc4b-47d1-9d75-7805364aac57)
