Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (26 sloc) 1.21 KB

console4Worker is console.* API for WebWorkers.

WebWorkers are hard to debug. On top of that, console.* API is unavailable in WebWorkers. It doesn't help. console4Worker is a simple library which try to fill this gap. See the demo in the examples/ directory.

On the Worker Side

First you include the script with


Then you use console.* as you would normally do. Lets say something like

console.log("console call made from inside a webworker");

On the Page Side

To include the script, simply do

<script src="console4Worker-page.js"></script>

Then in your message event listener, add the following line

if( console4Worker.filterEvent(event) ) return;

So you should have something like

worker.addEventListener('message', function(event){
    // filter this event if it is from console4Worker
    if( console4Worker.filterEvent(event) ) return;

    // ...
    // here handle your own events

}, false);

how does it work ?

a console.* object is declared in the worker. It intercepts all console.* calls and pass them to the page thread. a direct approach.

Jump to Line
Something went wrong with that request. Please try again.