// MAIN JS THREAD
const worker = new Worker('url/to/your/worke.js')
worker.onmessage = message => {
if (message === 'online') {
// do something
return
}
// here can be your code that handles main response of the worker
}
// WORKER.js
postMessage('online')
// here you can evaluate some highload code
// that you didn't want to block maon thread
postMessage('result of highload code')