Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (typeof Worker !== 'undefined') {
- // Create a new
- const worker = new Worker('./web-worker.worker', { type: 'module' });
- worker.onmessage = ({ data }) => {
- console.log(`page got message: ${data}`);
- };
- worker.postMessage('hello');
- } else {
- // Web Workers are not supported in this environment.
- // You should add a fallback so that your program still executes correctly.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement