Other people's selections

An article drawn by a canvas, with the selections of other readers drawn into it. Two simulated readers select sentences. Select some text yourself, then press “Show a second reader” to get a second copy of the page in a frame: a selection made in either copy appears in the other. A copy open in another tab joins too.

Reading the same page

When two people read one document, each of them can see what the other has selected. A shared editor does this by sending the start and end of the selection, not the pixels, and each reader's own copy of the page draws the mark.

A browser keeps one selection per document, and in Chrome it holds one range. So another reader's selection can't be a second real selection. It has to be drawn some other way: wrapped in elements, registered as a custom highlight, or painted by a canvas that knows where the text is.

Here the canvas draws them. Each reader has a colour, a bar at the end of the selection that is still moving, and a flag with a name. Your own selection is drawn the same way and stays a real selection that can be copied.

Open in a new tab
Show the code offsets, the channel and the drawing
  1. The article inside <selection-fx> with the effect named peers.
  2. A selection as two numbers. Character offsets into the article's text, and the way back to a Range.
  3. Send and receive over a BroadcastChannel. A server would relay the same message between people.
  4. Rectangles of a range in the element's own pixels.
  5. Draw every reader: rectangles under the text, a bar and a name flag over it.
  6. The simulated readers.

How it works

Each copy of the page listens for selectionchange, converts its selection to a start and an end offset in the article's text and posts them on a BroadcastChannel. A copy that receives offsets builds a Range from them, reads getClientRects() for each text node in it, and draws the rectangles in the canvas before the text and the flag after it. The receiving page's DOM and its own selection don't change. Tabs and frames of one origin share the channel. Between two people the same message would go through a server.

Live checks

These start when you press the button. They use their own fixtures and their own channel.

Findings

Measured in headless Chromium 157 on Linux with a software renderer, 2026-11-21.

Not verified: selecting by touch in the page and in the frame on a phone, and two phones through a server (this page has no server, only a channel inside one browser).