You are developing an HTML5 page named main.html. The JavaScript code for the main page is located in a file named myApp.js.
You need to create a web worker and instantiate it from main.html.
Where should you place the web worker code?
A. In the myApp.js file
B. In the main.html file
C. In a separate .js (JavaScript) file
D. In a separate executable file
Explanation:
Spawning a dedicated worker
Creating a new worker is simple. All you need to do is call the Worker() constructor, specifying the URI of a script to execute in the worker thread (main.js):
var myWorker = new Worker(-worker.js-);
Reference: Using Web Workers