JavaScript HTML5 Master/Slave Browser Tabs Helper

Version 1.2.7
16 Oct 2016

What is DuelJS?

DuelJS is a fast and small JavaScript helper for master/slave browser tabs actions. Use it for optimize your client-server communication between browser and server and inside browser tabs.

A Brief Look

Basic entity of DuelJS is channel. Channel provides unique community between browser tabs inside one site:

var channel = duel.channel('example'); // build your channel

Each window has 2 possible states: Master and Slave.
Master window - is a tab which currently working (has focus).
The simple method for detection is:


You can use it for get chat messages as example:

if (window.isMaster()) {
    updateChatWindow(); // user function

The More The Better

You want something more? Oh yeah we have. The Broadcast is a system for broadcasting your messages to all specific channel’s members (tabs), just see this example:

<script type="text/javascript">
    var channel = duel.channel('test');
    document.title = 'Master ' + duel.getWindowID();

    channel.on('demo_trigger', function (message) {
        console.info((new Date).getTime(), message)

    setInterval(function () {
        document.title = (window.isMaster() ? 'Master ' : 'Slave ') + duel.getWindowID();
    }, 100);
<button onclick="channel.broadcast('demo_trigger', 'hello world')">
    channel.broadcast('demo_trigger', 'hello world')


Bower support

Install package with bower:

bower install duel --save

NPM support

Install package with npm:

npm install dueljs --save

ES6 import

If you are using ES6 with babel/webpack, you need to import dueljs like on example below:

import duel from 'dueljs'

Online demo

Look at this in your browser right now: click here


DuelJS documentation now available on dueljs.readthedocs.org


Now you can determine a superMaster tab which will be it regardless of anything
Beta extension available on github.com/studentIvan/tabninja
Look at this in your browser right now: click here

bower install tabninja --save

Support or Contact

Having trouble with DuelJS? Contact mail@studentivan.ru and i’ll help you sort it out.
Check my site for information about me: studentivan.ru