Loads the light logo after the page load

Lazy loading saved its bytes during page load, but left the logo empty for a
moment when navigating to the homepage on a wide screen. Also adds the second
unit's code summary and the shared docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 01:56:13 +01:00
co-authored by Claude Opus 5.5
parent b965b8a227
commit b5fd83256d
14 changed files with 176 additions and 37 deletions
@@ -0,0 +1,64 @@
# Code Summary - Unit 2: Display fallbacks
Plan: [display-fallbacks-code-generation-plan.md](../../plans/display-fallbacks-code-generation-plan.md). Worktree `AndreaSlopFotografie-prerendering`, branch `feature/prerendering`, on top of unit 1 (`8dc120e`). File list from `git diff --name-status 8dc120e HEAD -- web` plus the uncommitted logo fix (see below).
## Status
- Steps 1 to 29 done (checked in the plan). Verification (Step 23): lint, format, test, build, e2e, audit:deps, audit:dev green.
- Measurement (Part H) done: [measurement-display.md](measurement-display.md). BR-DMS-05 decision rule not triggered (`/portfolio` mobile E 0.93, D 0.91, E2 0.93; desktop 0.99).
- After the measurement the logo flash (V-D7) was fixed; see "Logo fix".
## Commits
`4412515` Reveal, deferred images and the first row; `01fcfee` fallbacks without JavaScript; `2754890` browser tests; `d11fcb1` verified before measuring; `b965b8a` measurement. The logo fix is to be committed by the main session (to be filled by the main session).
## Files
### Reveal (BR-RVL-01 to 14; FR-PR-09, 10)
- Created: `web/src/lib/revealPhase.ts` (+ test, P18 to P21), `web/src/test/revealArbitraries.ts`.
- Modified: `web/src/hooks/useReveal.ts` (+ test), `web/src/components/Reveal/Reveal.tsx` (+ test): visible in the HTML and first render, a layout effect hides an element wholly below the viewport, no transition on hiding.
### Deferred images and no-JavaScript CSS (BR-IMG-01 to 10; FR-PR-11)
- Created: `web/src/components/NoScript/noScriptCss.ts` (+ test), `NoScriptStyles.tsx`.
- Modified: `web/src/components/DeferredImage/DeferredImage.tsx` (+ test) (`<noscript>` twin), `web/src/routes/__root.tsx` (head `<noscript><style>`).
### Menu without JavaScript (BR-NAV-01 to 12; FR-PR-12)
- Created: `web/src/components/NavigationBar/NoScriptNav.tsx` (+ test).
- Modified: `NavigationBar.tsx` (+ test), `MobileNav.tsx`, `MobileNavGroup.tsx`, `NavSubmenu.tsx` (ids and `data-*` markers).
### Other fallbacks (BR-NJS-01 to 11; FR-PR-13, 22)
- Modified: `Hero/Hero.tsx`, `HeroArrows.tsx`, `HeroPauseButton.tsx` (+ `hero.noscript.test.tsx`), `FilterBar/FilterBar.tsx`, `home/Testimonials/Testimonials.tsx`, `Footer/Footer.tsx`, `FooterColumn.tsx` (+ tests): `data-requires-js` markers.
### First photo and preload (BR-PRE-01 to 12; FR-PR-21)
- Created: `web/src/lib/firstRow.ts` (+ test, P24, P25), `web/src/test/firstRowArbitraries.ts`.
- Modified: `web/src/seo.ts` (`preloadImage`, P22) (+ test), `PortfolioGrid/PortfolioGrid.tsx` (`eagerFirstRow`, `<picture>` tiles) (+ test), `portfolio/PortfolioGallery/PortfolioGallery.tsx` (+ test), `routes/portfolio.tsx`, `routes/contact.tsx`, `ContactDetails/ContactDetails.tsx` (+ test).
### Tests (BR-DTS-01 to 05)
- Created: `web/src/displayHydration.test.tsx`, `web/src/displayPrerender.test.tsx`, `web/e2e/{displayHtml,noJs,noJsMenu,reveal,images}.e2e.ts`.
- Modified: `web/e2e/interaction.e2e.ts` (comment only), `web/e2e/support/browser.ts`.
### Documentation
- `construction/display-fallbacks/code/`: `baseline-checks.md`, `verification-log.md`, `proof-report.md`, `measurement-display.md`, this file. BR-PRE-05 and the `NavigationBar` row in the functional design were amended for the logo fix.
## Logo fix (after V-D7)
The measurement showed that a permanently lazy light logo flashes (one empty frame, local server) on a client navigation from a page other than `/` to `/` at 1350 px, because a lazy `display: none` image is only fetched once shown. Fix (owner decided): `NavigationBar` sets `loading="lazy"` on the light logo only while `!isHome && !pageLoaded` (`usePageLoaded`; the first render equals the HTML). Evidence in Chrome (probe and `images.e2e.ts`): at 412 and 1350 px on `/over-mij` the light logo is requested once, after `load`, never before; the flash is gone on navigation to `/` after load. A navigation before `load` may still flash briefly (accepted). Tests: a case in `NavigationBar.test.tsx`; `images.e2e.ts` "logo's" (requested once after load off `/`, before load only on `/`, no flash on navigation) replaces the old "only on `/`" test.
`/privacyverklaring` and the 404 page: the LCP element is the lazy footer logo (alt "Andrea Slop Fotografie", lazy since before this unit); the header logo is eager. Lab effect, nothing changed.
## Test inventory
- Unit: 130 files, 1277 tests (baseline 123 files, 1179 tests), coverage thresholds met, seed 2056055883 in the last run. Properties: P18, P19 (`startsHidden`), P20, P21 (`nextRevealPhase`), P22 (`preloadImage`), P24, P25 (`firstRow`, `firstRowPreloads`); P23 is an example test.
- Browser: 9 files, 214 tests (baseline 4 files, 77 tests in the Step 1 count; 212 before the logo fix, +2).
- Existing tests changed: see plan section 6 (the `useReveal` cases, `PortfolioGrid`, `PortfolioGallery`, the `noScriptCss` group rule, `interaction.e2e.ts` comment, and now the logo test).
## Verification points (condensed, details in verification-log.md)
V-D1, V-D2, V-D3, V-D5, V-D6, V-D7, V-D8, V-D9, V-D11, V-D12, V-D13, V-D14, V-D15 OK. V-D4: Chrome OK (scroll position kept); **Firefox, Safari and Chrome on Android need a person**. V-D10: **BLOCKED**, no trace (`pnpm exec lighthouse` does not exist); the heading is the LCP element on `/` in the report and the probe.
## Deviations
None from the design. V-D7 found the logo flash, fixed as above (amends BR-PRE-05).
## What unit 3 can rely on
Every page is visible without JavaScript; photos show through `<noscript>` twins; the menu works through `:target`; the head `<noscript><style>` carries all no-JS CSS; `preloadImage` and `firstRow` exist for preload links; nothing in server rules was changed (nginx, IIS, CSP untouched). Unit 3 measures again at the end.
## Open points for the owner
- V-D4 in Firefox, Safari and Chrome on Android (human check).
- V-D10 (no trace).
- Mobile scores still under 0.9: `/` 0.85, gezin 0.89, loveshoot 0.88 (BR-DMS-04); `/portfolio` LCP 3232 ms (photo is the largest paint) with score 0.93.
- A navigation before `load` can still flash the light logo briefly.
@@ -72,7 +72,7 @@ Script transfer on mobile (median, bytes): `/` 222,660 (A 221,110), `/over-mij`
- `/contact`: equal to A (0.94, 3007 ms); better than master.
- `/portfolio`: 0.93 against A 0.94, LCP 3232 against 3007 (+225 ms), because a photo is now the largest paint. Better than B (0.90, 3607) and than D (0.91, 3459).
- `/`: 0.85 and 4356 ms, equal score and +76 ms against A (expected "unchanged").
- `/privacyverklaring` (+150 ms) and not found (+73 ms) LCP are later than A with equal scores; the LCP element is the dark logo, now lazy. Not an expected change; reported.
- `/privacyverklaring` (+150 ms) and not found (+73 ms) LCP are later than A with equal scores; the LCP element is the footer logo (`alt` "Andrea Slop Fotografie", `loading="lazy"`, unchanged by this unit), the header logo being eager. A lab effect; nothing changed.
## BR-DMS-04: still open
@@ -91,9 +91,9 @@ Script transfer on mobile (median, bytes): `/` 222,660 (A 221,110), `/over-mij`
## V-D7: lazy logos and contact portrait
- Image KB requested before the real LCP on non-home pages: the light logo (24.8 KB) is no longer in the list; only the dark logo (23.5 KB) is (`/over-mij` 107 KB, soorten 97 KB). `/` still requests both logos (total 272 KB with the 224 KB hero). The contact portrait is 5.9 KB on mobile contact, where it is displayed.
- Score and LCP A to U2: see the BR-DMS-03 list. The gains on photo pages combine this with the visible `Reveal`; this measurement does not separate the two.
- `/privacyverklaring` and not found: the LCP element is the lazy footer logo (alt "Andrea Slop Fotografie"); the header logo is eager. The footer is unchanged by this unit, so the +150 and +73 ms are a lab effect, not the logo change. Score and LCP A to U2: see the BR-DMS-03 list. The gains on photo pages combine this with the visible `Reveal`; this measurement does not separate the two.
- Logo flash, probe on client navigation `/` to `/over-mij` and back (logos already cached from `/`): no frame with a displayed, incomplete logo.
- **Finding**: fresh load of `/over-mij`, then client navigation to `/` at 1350 px: the light logo is requested only then, and 1 sampled frame shows the light logo displayed (46 px) while incomplete with the dark logo already hidden (an empty logo area for that frame on a local server; longer on a slow network). At 412 px no such frame (light logo not displayed). Not fixed; for the owner.
- **Finding**: fresh load of `/over-mij`, then client navigation to `/` at 1350 px: the light logo is requested only then, and 1 sampled frame shows the light logo displayed (46 px) while incomplete with the dark logo already hidden (an empty logo area for that frame on a local server; longer on a slow network). At 412 px no such frame (light logo not displayed). **Fixed afterwards**: the light logo is lazy only until `load`, then eager; verified in Chrome and in `images.e2e.ts`. A navigation before `load` may still flash briefly (accepted).
## V-D10: hero photo and LCP in a trace
@@ -10,7 +10,7 @@ Status values: `open` (not yet settled), `OK`, `BLOCKED`, `DEVIATION`.
| V-D4 | Fragment navigation to a fixed element does not scroll in Firefox and Safari, and Chrome on Android (only desktop Chrome was probed). If one scrolls, the fixed `header` target moves to a zero-size fixed element. | 17 | Chrome part OK; Firefox, Safari and Chrome on Android need a person. | e2e/noJsMenu.e2e.ts: opening via #mobile-nav and closing via #site-header leave scrollY at 300 on /over-mij and / at 390 x 800. | open (Chrome OK, other browsers need a person) |
| V-D5 | The comparison of BR-DMS-05 (E against D on mobile, three runs each, same machine) and its report to the owner when E is below 0.9 or below D. | 26 | E mobile 0.93, D 0.91, E2 0.93; desktop 0.99 for all; rule not triggered | measurement-display.md | OK |
| V-D6 | Height of every `Reveal` at 320, 360, 412, 768, 1350 px wide against the limit of BR-RVL-13. | 18 | Every hidden Reveal stays far below the limit (320: 4233 px, 360: 4833, 412: 6358, 768: 8033, 1350: 7333). | e2e/reveal.e2e.ts, hidden Reveals after hydration plus 2 s, tallest per page (px) at 320/360/412/768/1350: / 649/649/649/998/585; /over-mij 465/443/512/230/408; /portfolio 481/541/619/511/223; /soorten-fotoshoots 551/479/391/470/470; newborn 784/712/712/600/624; zwangerschap 784/712/712/600/600; gezin 784/712/712/600/600; loveshoot 736/688/688/568/336; portret 736/688/688/568/336; /contact 670/0/0/0/0; /privacyverklaring 0. | OK |
| V-D7 | After the gate measurement: whether `loading="lazy"` on the light logo and the contact portrait changes score and LCP as estimated; that the logo does not flash on `/` or on a client navigation from `/` to another page and back. | 24, 25 | Light logo gone from pre-LCP bytes off the home page; no flash with cached logos; one empty-logo frame on fresh /over-mij then client nav to / at 1350 px | measurement-display.md | DEVIATION |
| V-D7 | After the gate measurement: whether `loading="lazy"` on the light logo and the contact portrait changes score and LCP as estimated; that the logo does not flash on `/` or on a client navigation from `/` to another page and back. | 24, 25 | Light logo gone from pre-LCP bytes off the home page; no flash with cached logos; one empty-logo frame on fresh /over-mij then client nav to / at 1350 px; fixed: light logo lazy only until load (usePageLoaded), requested once after load at 412 and 1350 px, no flash after load; a navigation before load may still flash (accepted) | measurement-display.md, e2e/images.e2e.ts | OK |
| V-D8 | The raw-HTML e2e tests that count `img` or links (`rawHtml.e2e.ts`) with `noscript` content present. | 20 | The unit-1 raw-HTML tests pass unchanged with noscript content present. | rawHtml.e2e.ts uses toContain on nav targets and removes noscript before reading text; it counts no img and no links, so no change was needed. Only the comment in the interaction.e2e.ts V15 block was updated. | OK |
| V-D9 | The visible focus ring of the two menu links in Chakra's reset (a bare `a` outside Chakra components). | 17 | The focused open and close links have a visible focus ring. | e2e/noJsMenu.e2e.ts: computed outline width of nav-noscript-open and nav-noscript-close, reached with Tab, is at least 2 px. | OK |
| V-D10 | Whether Chrome really excludes the viewport-filling hero photo from LCP (so text is the candidate on `/`), by a trace. Only explains `/`; changes no rule. | 25 (only if a trace exists) | Trace not obtained: pnpm exec lighthouse not found | measurement-display.md | BLOCKED |