From e0d492c438f59efa1daad9be5cc4d9dddd4e1b0b Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Tue, 17 Nov 2026 08:16:41 +0100 Subject: [PATCH] Docs: oorzaak en oplossing van de layoutverschuiving (CLS) bij het opstarten Co-Authored-By: Claude Sonnet 5.5 --- docs/hero-integration.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/hero-integration.md b/docs/hero-integration.md index f5d12cb..6c44c69 100644 --- a/docs/hero-integration.md +++ b/docs/hero-integration.md @@ -34,3 +34,9 @@ The only change in the prerendered text compared with the build before this feat ## Open points for the CMS host See the report of this feature: the host renders the hero region only when the hero has a usable slide, and it writes picture/`h1` HTML without the lead. For this text-only site the region therefore stays the baked hero and the visitor gets the CMS text from the data block after the app has loaded. The site already styles the host's `cms-hero-*` classes (`src/index.css`) for the day the host can write a text-only region. + +## Layout shift (CLS) at start-up + +Measured on the test site (mobile, 4x CPU, slow 4G): CLS 0.35-0.40, one shift on `#root`. Cause: not the hero swap (that is about 1 px, CLS 0.0007) but the static packages list `#packages-static` that the host injects above `#root` (about 288 px high, visible) and that `main.tsx` removes at start-up, which moves the whole page up. A second, smaller shift (0.045, platform dependent) came from the code line of the hero re-wrapping when JetBrains Mono replaced the generic `monospace` fallback. + +Fixes: `index.html` takes `#packages-static` out of the layout (visually hidden, still in the HTML for crawlers); `src/index.css` defines `JetBrains Mono Fallback` (Courier New / Liberation Mono / Cousine, same 0.6em advance) in front of `monospace`. After the fix CLS is 0.000 locally (390, 412 and 1350 px wide). No change to the host markup is needed: the `cms-hero-*` region and the React hero take practically the same space.