--- title: Web Workers pagination_prev: demos/extensions/index pagination_next: demos/engines/index sidebar_custom_props: summary: Run large data flows without freezing the browser --- import current from '/version.js'; import CodeBlock from '@theme/CodeBlock'; Parsing and writing large spreadsheets takes time. During the process, if the SheetJS library is running in the web browser, the website may freeze. Workers provide a way to off-load the hard work so that the website does not freeze during processing. The work is still performed locally. No data is sent to a remote server. The following diagrams show the normal and Web Worker flows when exporting a dataset. The regions with a red background mark when the browser is frozen.
Normal Export | Web Worker Export |
---|---|
```mermaid sequenceDiagram autonumber actor User participant Page User->>Page: click button rect rgba(255,0,0,.2) activate Page Note over Page: collect dataset Note over Page: generate workbook Note over Page: create file Note over Page: setup download end Page->>User: download workbook deactivate Page ``` | ```mermaid sequenceDiagram autonumber actor User participant Page participant Worker User->>Page: click button rect rgba(255,0,0,.2) activate Page Note over Page: collect dataset Page->>Worker: transfer dataset end deactivate Page activate Worker Note over Worker: generate workbook Note over Worker: create file Note over Worker: setup download Worker->>Page: URL to download deactivate Worker activate Page Page->>User: download workbook deactivate Page ``` |
State: {state}
Count: {cnt} ({hz|0} Hz)
> ); } ```