diff --git a/aio/content/guide/web-worker.md b/aio/content/guide/web-worker.md index 2bec5b635c..c05bae8093 100644 --- a/aio/content/guide/web-worker.md +++ b/aio/content/guide/web-worker.md @@ -1,17 +1,31 @@ -# Using web workers with Angular CLI +# Background processing using web workers -[Web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) allow you to run CPU intensive computations in a background thread, freeing the main thread to update the user interface. +[Web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) allow you to run CPU-intensive computations in a background thread, +freeing the main thread to update the user interface. +If you find your application performs a lot of computations, such as generating CAD drawings or doing heavy geometrical calculations, using web workers can help increase your application's performance. -If you find your application becomes unresponsive while processing data, using web workers can help. +
addEventListener('message', ({ data }) => { @@ -20,7 +34,7 @@ Running this command will: }); -- add scaffolded code to `src/app/app.component.ts` to use the worker: +- Adds the following scaffold code to `src/app/app.component.ts` to use the worker. if (typeof Worker !== 'undefined') { @@ -36,11 +50,10 @@ Running this command will: } -After the initial scaffolding, you will need to refactor your code to use the web worker by sending messages to and from. +After you generate this initial scaffold, you must refactor your code to use the web worker by sending messages to and from the worker. -## Caveats +