Prime Numbers in JavaScript using Web Workers
Mt. Ford Studios
In this JavaScript tutorial, we learn how to generate prime numbers using a HTML5 Web Worker. Web Workers are simply background processes that can be run without interfering with the user interface. We start off by creating a form where the user can input the number of primes required. We pass that information to our web worker in order to calculate that number of primes. During the process, we tell the web worker to send its progress to the main thread so that we can update the web page. It’s all pretty nifty!
Go ahead and download the code below to set up your own prime number web worker!
JAVASCRIPT TEMPLATE https://drive.google.com/open?id=1W8vbBTBFf7gBTnZ04bNSy6ywRgRSSeQN
CODE javascript-primes.html: https://drive.google.com/open?id=1NRbS5a5ciel6pz0vZYTxQG-UcAYi843S primes-worker.js: https://drive.google.com/open?id=1T-VBCqftJ9EUJXXJN0AJyYlLY6sdHr0u
USEFUL LINKS HTML5 Web Workers: https://www.w3schools.com/htmL/html5_webworkers.asp Using Web Workers: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers Visual Studio Code: https://code.visualstudio.com/
FIND US ON FACEBOOK https://www.facebook.com/MountfordStudios/ ... https://www.youtube.com/watch?v=7ZTfaq2Bsmw
53529445 Bytes