Shorten a JavaScript string at its start, middle, or end while reserving room for a suffix.
The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.
Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.
The suffix length is subtracted from the maximum before UTF-16 slicing keeps a prefix, suffix, or two equal halves. Word preservation may retreat to a nearby ordinary space; when the suffix consumes the allowance, only a sliced suffix remains.
Input: The quick brown fox jumps over the lazy dog in the garden Max length: 30
The quick brown fox jumps...
Search cards shorten descriptions, log viewers retain long-line tails, and filename previews preserve both a beginning and extension.