Skip to content

Instantly share code, notes, and snippets.

@frank-dspeed
Last active June 1, 2021 07:05
Show Gist options
  • Save frank-dspeed/4329024ebcc59ae9e98935694586c1ff to your computer and use it in GitHub Desktop.
Save frank-dspeed/4329024ebcc59ae9e98935694586c1ff to your computer and use it in GitHub Desktop.
BOOK

How to use Webworkers

Do always use a webworker always with a single file bundle do never split web worker code into modules. WebWorkers have a limited life cycle thats why they are not designed to run multiple modules they are designed to shift of long running processing from the main th and should not get abused for other stuff

The costs of context switching between the Main and the Worker is to high so only use it for operations that take at last 500ms in general even a operation that takes 100ms is a valid usecase but it depends on the overall time that your app blocks the main th. So batch processing is also a valid usecase.

@coxdenis32
Copy link

Thanks for the advice. I have been looking for an option with a multi-module system for a long time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment