Worker Module
Usage
To be used in the browser with a module bundling system, like browserify.
var myModule =myWorker = myModule;
Full example
my-worker.js:
module{"use strict";{;}}
Main JS:
var myModule =createWorker = myModuleworker1 =worker2 = ;myWoker1 {console;}myWoker2 {console;}worker1;worker2;
Why
Web workers need a URL to a script in order to run it. This results in an extra request to the server, and goes against our efforts to concatenate all scripts and work in a single, clean, modular way.
How it works
The script behind this is tiny, so take a look. It uses the blob method; a blob is created for the module, the url of which is passed to the worker constructor.
Compatibility
IE | Edge | Firefox | Chrome | Safari | Android |
---|---|---|---|---|---|
10 | Yes | Yes | Yes | Yes | 5 |
License
This project is licensed under the ISC License - see the LICENSE.md file for details