browser as a worker


compute on the client side

npm install baaw --save

baaw is a small library on top of that allows delegating work to the remote browsers in few small steps (working example):

  var baaw = require('baaw')(io, '');
    .get('/script', function (req, res) {
      res.setHeader('content-type', 'text/javascript');
  <script src="" type="text/javascript"></script>
  baaw.on('new', function (worker) {
    // New worker (browser) connected
    var executor = function (color, manager) {
      // Below code will be executed in browser = 'red';
      jobManager.sendResult('I\'ve change background color!');
    // Data passed to executor
    var data = 'red';
    var onDone = function (result) {
      // Below code will be excuted in node after sending result from browser
      console.log('Browsers result:', result);
    };, data, onDone);
  • io - instance
  • url - url where will host client side library


  • new - new browser connected, callback gets worker (an instance of BrowserWorker) as a first argument

delegate some work to browser

  • executor(data, manager) - function that will be executed in browser,
  • data - data that will be passed as first argument to executor
  • onDone(result) - function that will be executed on server side when browser will finish execution

JobManager instance is passed to executor function as a second argument. It's used to send result to server.

  • sendResult(result) - send result back to server, after that onDone will be called with result.