MDN Specification

Notes

Note that we use self for the worker to give a global reference to web workers because it is not a window object.

Event listener in the main script:

    //main.js
    let worker = new Worker('worker.js');
    worker.addEventListener('message', function(e) {
    // Log the workers message.
    console.log(e.data);
    }, false);

MDN Reference: Functions and classes available to Web Workers

The following functions are available to workers:

The following functions are only available to workers:

The following Web APIs are available to workers:


Tags: platform   browser  

Last modified 26 July 2025