// index.js
var worker = new Worker('worker.js');
worker.postMessage('ping');
worker.onmessage = function (e) {
console.log(e.data); // 'pong'
};
// worker.js
self.onmessage = function (e) {
console.log(e.data); // 'ping'
self.postMessage('pong');
};
btoa()
, atob()
main.js | 24.1kB |
worker.js | 90.9kB |
serviceWorker.js | 15.8kB |