Repository navigation
Description
Summary
The Streams data-type page renders to a ~41 MB HTML document containing 1,279,161 <span> elements. This makes the page extremely slow to load, janky to scroll, and capable of freezing the browser tab. It also breaks tools that fetch the page (they hit content-size limits).
Affected page: https://redis.io/docs/latest/develop/data-types/streams/
This is reproducible directly from the live site (not a CDN/client-side issue).
How bad it is, relative to sibling pages
| Page | Raw HTML size |
|---|---|
| streams | ~41 MB |
| lists | ~16 MB |
| sets | ~6 MB |
| sorted-sets | ~5 MB |
| hashes | ~2 MB |
| strings | ~2 MB |
Root cause
layouts/partials/tabs/source.html reads and embeds the entire example source file, for every step, for every language:
{{ $rawContent := readFile .contentPath }}
{{ $content := highlight $rawContent .language .options }}
{{ return $content }}
The per-step line range from named_steps is passed only as hl_lines (see layouts/partials/tabbed-clients-example.html, around the hl_lines option). hl_lines merely highlights lines — Chroma still emits the whole file as HTML. So each clients-example invocation re-embeds the complete source file rather than the relevant snippet.
Proof that the whole file is embedded every time
Measuring the rendered <pre class="chroma"> blocks on the Streams page (which has 34 example steps):
| lang | blocks | avg lines/block | max lines/block | avg KB/block | max KB/block |
|---|---|---|---|---|---|
| rust | 68 | 928 | 961 | 274 | 279 |
| go | 34 | 909 | 918 | 146 | 146 |
| c# | 34 | 491 | 500 | 83 | 83 |
| python | 34 | 337 | 345 | 54 | 54 |
| node.js | 34 | 278 | 284 | 58 | 58 |
| java | 34 | 177 | 179 | 76 | 76 |
For every language, avg block size == max block size, and the line count matches the full source file (e.g. the Go tutorial file is ~912 lines and every Go block renders ~909–918 lines). If snippets were sliced per step, block sizes would vary per step (e.g. an xadd step vs an xrange step). They don't — confirming the whole file is embedded 34 times per language.
This affects all pages; it's just most visible on the longest tutorials. Even Go alone contributes ~5 MB on the Streams page (146 KB × 34).
Why Rust dominates (46% of the page)
Two compounding factors, on top of the root cause:
- Pulled twice —
Rust-SyncandRust-Async(config.tomlclientsExamples) both map toclientId="redis-rs"and resolve to the same source file, so it's embedded 68 times instead of 34. - Denser highlighting — Rust's syntax (generics,
::paths, type annotations) produces ~2× the bytes per line vs Go (~295 vs ~160 bytes/line).
Note: Rust is not malformed or unusually long (~928 lines, comparable to Go's ~909). The issue is structural in the partial, not in the redis-rs source.
Suggested fix
Make layouts/partials/tabs/source.html (or the caller) slice the source to the step's line range before highlighting, instead of relying on hl_lines. The line range already exists in named_steps. Roughly: split $rawContent on newlines, take the named_steps range, then highlight only that slice. This fixes the bloat for all languages at once.
I'm happy to raise a PR if a maintainer can confirm this is the preferred approach (slice-in-partial) vs. an alternative (e.g. generating per-step files at build time).
Activity
mich-elle-luna commentedon Jun 3, 2026
Hi @EliShteinman
Thanks for raising this and analyzing it, much appreciated. We have been talking about this page and its size as well. Assigning to David for his thoughts when he has time, he and I can discuss this Friday and let you know.
mich-elle-luna commentedon Jun 8, 2026
Hi, after a discussion it seems that this proposal would disable the eyeball feature, so we want to look at alternate ways to solve the problem you surfaced. David investigated this with claude Friday and another possible solution we are reviewing is as follows:
Solution overview
For each panel where a per-step
named_stepsrange exists:.step-code-view, shown fully by default.hidden
<template id="tce-fullsrc-{key}">.data-fullfile-keyanddata-hl-range..full-file-view, re-tagsthe range lines as
.hl(existing dimming CSS handles the rest), hides.step-code-view, and setsaria-expanded; collapse removes the clone andrestores the snippet.
Panels with no per-step range (no
named_stepsfor the step) keep today'sbehavior (highlight whole file with example-level
hl_lines) — they aren't thebloat driver, and because all CSS changes are scoped to
data-fullfile-keytheyare left completely intact. redis-CLI panels are untouched (separate
max-heighttrim path; eyeball already hidden for them).
thanks,
Michelle
EliShteinman commentedon Jun 14, 2026
I've opened #3497, which implements the slice + hidden full-file
<template>+ eyeball-clone approach David outlined above.Each step now renders only its
named_stepsslice by default, and the full highlighted file is embedded once per page in a hidden<template>(deduped by file). The eyeball clones that template on demand and re-tags the step's lines, so the "show the step in context of the whole file" behaviour is preserved exactly. To avoid losing syntax-highlight context, the whole file is highlighted first and the rendered lines are sliced.Result on a local build (all clients, incl. Rust): Streams 41.6 MB → 7.3 MB, and no page exceeds 10 MB. Happy to adjust anything in review.
Merge pull request #3497 from EliShteinman/fix/clients-example-snippe…