Skip to main content

Tools — Build it yourself

Two-Tab Scoreboard Sync (BroadcastChannel)

Open this page in a second tab of the same browser. Then change the score in either tab — add points, rename a team, advance the period — and watch the other tab follow instantly. No account, no refresh, and no server in the middle: the two pages are talking directly to each other through a browser API called BroadcastChannel.

The mechanism is deliberately small. Any tab can create a channel with a name — this page uses “soe-v11-scoreboard” — and post a message to it. The browser delivers that message to every other tab, window, or frame on the same origin that has opened a channel with the same name. Same origin is the security boundary: pages from a different site cannot listen in or inject messages, because the browser checks where each context came from before it delivers anything. One quirk shapes the code: a channel object never receives its own messages. That is why this single page holds two channel objects — one that posts from the control panel and a separate one that listens for the display panel — which also proves the point that delivery is between contexts, not within one script.

What travels is a small object: two team names, two scores, and the period. The receiving side treats every message as the complete new state rather than a difference, which keeps the logic honest — a tab that missed a message, or opened late, still lands on the right score with the next update instead of drifting. That full-state habit is worth stealing for any synchronization you build, on any transport.

The honest limits matter as much as the trick. BroadcastChannel reaches only the same browser on the same device: it cannot sync your phone with your laptop, it does not persist anything when the last tab closes, and it offers no delivery guarantee beyond the tabs that are open right now. Real multi-device scoreboards need a server or a peer connection for exactly those reasons. But for the press-box pattern — a control tab the scorer drives and a clean display tab on a second screen — the browser already ships everything required, and this page is the whole system. If your browser lacks the API, the panel below says so plainly instead of failing silently.

Loading the scoreboard…