Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 1.68 KB

browser.md

File metadata and controls

41 lines (25 loc) · 1.68 KB

Browser

IndexedDB

Micro / Macro tasks

Webworkers - Dedicated Workers

They make it possible to run a script in a background thread separate from the main execution thread. It allows the UI to run without being slowed down.

Almost any code can be run inside a worker thread but DOM manipulataion functions, or default methods from the window object.

Overhead

Instantitation

Time to instantiate: 40ms Instantiating web workers is pretty efficient but one should try to create as few web workers and reuse them.

Message latency

postMessage is fast and takes less than 1ms to run. Transfer speed is about 80kB/ms for postMessage.

Communication

Data is sent between the worker and the main thread via a system of messages using the postMessage() method, and can respond to messages using the onmessage event handler. Data is copied rather than shared

Resources