Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. if (typeof Worker !== 'undefined') {
  2. // Create a new
  3. const worker = new Worker('./web-worker.worker', { type: 'module' });
  4. worker.onmessage = ({ data }) => {
  5. console.log(`page got message: ${data}`);
  6. };
  7. worker.postMessage('hello');
  8. } else {
  9. // Web Workers are not supported in this environment.
  10. // You should add a fallback so that your program still executes correctly.
  11. }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement