Содержание
- 2. WEB WORKERS Web Workers allow you to perform long in time and complex tasks without blocking
- 3. WEB WORKERS To start working with Web Workers, you need to create Worker object type, the
- 4. WEB WORKERS Please note, that the postMessage() method and the "message" event are used by both
- 5. WEB WORKERS To demonstrate how Web Workers work, let's create the following files: index.js – the
- 6. WEB WORKERS index.js file: const w = new Worker("worker.js"); w.addEventListener("message", (e) => { console.log("Main }); w.postMessage("Hello
- 7. WEB WORKERS worker.js file: console.log("Worker started"); addEventListener("message", (e) => { if (e.data !== "stop") { console.log("Main
- 8. WEB WORKERS We display the start of work in the browser console. Add a handler to
- 9. WEB WORKERS During the execution of Web Workers, errors may occur, the "error" event is responsible
- 10. WEB WORKERS An example of error handling. index.js file: const w = new Worker("worker.js"); w.addEventListener("error", (e)
- 11. WEB WORKERS worker.js file: console.log("Worker started"); addEventListener("message", (e) => { console.log(x); }); After running the code,
- 13. Скачать презентацию