Repository navigation
perf(docsite): a narrow screen loads the other hero slides only when the visitor uses the reel - #13705
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about the narrow-screen trade. No current spec decides when the home hero reel loads slide assets, and this change knowingly lets a first swipe on a slow connection show the new slide with the previous slide's photos and a fallback font; the closest record, spec:AST-033 DEC-5 (the current selection owns visible content), leaves open whether a hero slide counts as a selection. An engineering owner records the decision, or names the spec that settles it, by commenting /approve-spec followed by the full head commit SHA, and as an engineering owner you may do so yourself. No blocking code defect was found, and CI has not run on this draft yet.
- Optional:
warmNeighborsOfcould return early whenprefersReducedData()is true, as the docsite's template prefetch and theme showcase warm-up do, so Save-Data and 2G visitors skip the ahead-of-need slide.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claims:
- Below 1024 px the reel never auto-advances: verified (
HeroThemeReel.tsx:358-372). - Narrow screens no longer load the other slides at idle: verified (
HeroThemeReel.tsx:392-395). - The two neighbours load on 10 px of mostly sideways touch travel, on keyboard focus on the dots, and on each slide change: verified (
HeroThemeReel.tsx:467-481,:650-657,:345-356). - A scrolling, diagonal or 45-degree touch, a tap, and focus on a hero link load nothing: verified (
HeroThemeReel.tsx:476; the swipe area's focus handler only pauses). - A dot press loads the target's neighbours, and the target itself as it shows: verified (
HeroThemeReel.tsx:351-353). - Each slide loads once on the narrow path: verified (
startedSlides,HeroThemeReel.tsx:317-336). - Wide screens, reduced motion included, load every slide once with the same font and photo lists as before: verified (
HeroThemeReel.tsx:392-411;heroThemeContent.tslists against the base's). - The hydration render's wide answer is cancelled when the browser's narrow answer replaces it: verified (
useMediaQueryserver defaultfalse; cleanup atHeroThemeReel.tsx:410). - The loads start in handlers, the Effect only syncs the cache, and its cleanup runs on rerun and unmount: verified by reading.
- The new tests number 16 unit, 6 content and 4 browser tests and cover the rules listed: verified by reading; not run.
- The byte, request and timing measurements, the red-then-green browser run, the mutation check and the passing suites: not reproduced.
- The docsite's two linked records say nothing about when a page loads a font or photo: verified against
main;spec:AST-033DEC-5 is the closest claim. - The first-swipe trade was approved by the docsite owner: no public record; this is the decision approval waits on.
- Below 1024 px the reel never auto-advances: verified (
- Files:
apps/docsite/src/app/(site)/_landing/hero/HeroThemeReel.tsx: waits on the owner decision; optional data-saving note.apps/docsite/src/app/(site)/_landing/hero/heroThemeContent.ts: clear.apps/docsite/src/__tests__/hero-reel-warm-up.test.tsx: clear.apps/docsite/src/__tests__/hero-theme-content.test.ts: clear.apps/docsite/e2e/home-reel-warm-up.spec.ts: clear.
There was a problem hiding this comment.
Approval waits on an engineering owner deciding the narrow-screen loading trade: no current spec decides when the home hero reel loads slide assets, and this change lets a slide whose files have not arrived show the previous slide's photos and a fallback font, on a first swipe over a slow connection and on every newly visited slide for a Save-Data or 2G visitor. The closest record, spec:AST-033 DEC-5 (the current selection owns visible content, with stale content only under an explicit pending treatment), leaves open whether a hero slide counts as a selection. An engineering owner records the decision, or names the spec that settles it, by commenting /approve-spec followed by the full head commit SHA, and as an engineering owner you may do so yourself. The new data-saving check settles the earlier optional note, no code defect was found, and CI has not run on this draft yet.
Claims and files checked
Review mode: incremental; reason: none
- Claims:
- Below 1024 px the reel never advances by itself: verified (
HeroThemeReel.tsx:360-374). - Narrow screens no longer load the other slides at idle: verified (
HeroThemeReel.tsx:394-397). - The two neighbours load on 10 px of mostly sideways touch travel, on keyboard focus on the dots and on each slide change: verified (
HeroThemeReel.tsx:469-483,:652-660,:347-358). - A scrolling, diagonal or 45-degree touch, a tap, and focus on a hero link load nothing: verified (
HeroThemeReel.tsx:478; the swipe area's focus handler only pauses,:512). - A dot press loads its slide's neighbours, and the slide itself as it shows: verified (
HeroThemeReel.tsx:354). - Each slide loads once on the narrow path: verified (
HeroThemeReel.tsx:318-338). - A Save-Data or 2G visitor on a narrow screen gets no slide ahead of need: verified (
HeroThemeReel.tsx:326,lib/prefersReducedData.ts). - Wide screens, reduced motion included, load every slide once with the same font and photo lists as before: verified (
HeroThemeReel.tsx:394-413,heroThemeContent.ts:371-446). - The hydration render's wide answer is cancelled when the browser's narrow answer replaces it: verified (
useMediaQueryserver default is false; cleanup atHeroThemeReel.tsx:412). - The loads start in handlers, and the one Effect only syncs the cache and cleans up on rerun and unmount: verified by reading.
- The new tests number 18 unit, 6 content and 4 browser tests and cover the rules listed: verified by reading; not run.
- The byte, request and timing measurements, the red-then-green browser run, the mutation check and the passing suites: not reproduced.
- The docsite's linked specs say nothing about when a page loads a font or a photo: verified against the current specs.
- The docsite owner approved the first-swipe trade privately: no public record; this is the decision approval waits on.
- Below 1024 px the reel never advances by itself: verified (
- Files:
apps/docsite/src/app/(site)/_landing/hero/HeroThemeReel.tsx: waits on the owner decision.apps/docsite/src/app/(site)/_landing/hero/heroThemeContent.ts: clear.apps/docsite/src/lib/prefersReducedData.ts: clear.apps/docsite/src/__tests__/hero-reel-warm-up.test.tsx: clear.apps/docsite/src/__tests__/hero-theme-content.test.ts: clear.apps/docsite/e2e/home-reel-warm-up.spec.ts: clear.
…the visitor uses the reel After load the home page loaded the fonts and photos of every hero reel slide, so that the reel can advance by itself with no flash. Below 1024 px the reel does not advance by itself, and most visitors never see another slide: 334 KB that a phone downloads for nothing. A narrow screen now loads the two slides next to the current one when the visitor first moves a touch sideways on the reel or moves keyboard focus to its dots, and again after each change of slide. A wide screen loads every slide after load, as before.
…or who saves data On a narrow screen the reel loads the two slides next to the current one when the visitor starts to use it. One of them is in the direction that the visitor does not move. In a data-saving mode or on a 2G connection the reel now loads no slide ahead of need, as the docsite's other downloads ahead of need do.
4f1a21f to
ec6f037
Compare
|
/approve-spec ec6f037 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this draft head yet, so the merge guard still waits for the required checks.
The narrow-screen loading trade, where a slow first swipe shows the previous slide's photos and a fallback font until its files arrive, is decided by an engineering owner's /approve-spec for this head, and the review found no code defect. The earlier optional note about data-saving visitors is addressed by the prefersReducedData() return in warmNeighborsOf.
Claims and files checked
Review mode: full; reason: rebase
- Claims:
- Below 1024 px the reel never advances by itself and no longer loads the other slides after load: verified (
HeroThemeReel.tsx:365-379,:399-402). - The two neighbouring slides load on 10 px of mostly sideways touch travel, on keyboard focus on the dots and on each slide change: verified (
HeroThemeReel.tsx:481-485,:659-664,:358-360). - A scrolling, diagonal or 45-degree touch, a tap, and focus on a hero link load nothing: verified (
HeroThemeReel.tsx:483; the swipe area's focus handler only pauses,:517). - A dot press loads its slide as it shows and that slide's two neighbours, not those of the slide it leaves: verified (
HeroThemeReel.tsx:358-360and its unit test). - Each slide loads once on the narrow path: verified (
HeroThemeReel.tsx:323,:334-343). - A Save-Data or 2G visitor on a narrow screen gets no slide ahead of need, as the docsite's other ahead-of-need downloads do: verified (
HeroThemeReel.tsx:331;themeShowcaseWarmup.tsandtemplatePrefetch.tsuse the same rule). - Until a slide's files arrive it shows the previous slide's photos and a fallback font: verified (the card images keep their element and change source,
HeroFloatingCards.tsx:436-532). - Wide screens, reduced motion included, load the same fonts and photos in the same order as before: verified (
heroThemeContent.ts:398-400,:458-459;hero-theme-content.test.ts). - The hydration render's wide answer is cancelled when the browser's narrow answer replaces it: verified (
useMediaQueryreads a store whose server answer is false; cleanup atHeroThemeReel.tsx:417). - The preload gives each image its card's
sizesandsrcsetbefore itssrc, so it fetches the file the card shows: verified (HeroThemeReel.tsx:286-292,heroThemeContent.ts:462-474, the newhero-reel-photos.test.tsxcases). - Loads start in handlers, and the one Effect only syncs the cache and cleans up on rerun and unmount: verified by reading.
- The new tests number 18, 6 and 4, plus 2 new cases in a file of 10, and cover the rules listed: verified by reading; not run.
- The docsite's linked specs say nothing about when a page loads a font or a photo: verified against the current specs.
- Byte, request and timing measurements, the red-then-green run, the pixel comparisons, the mutation check and the passing suites: not reproduced.
- Below 1024 px the reel never advances by itself and no longer loads the other slides after load: verified (
- Files:
apps/docsite/src/app/(site)/_landing/hero/HeroThemeReel.tsx: clear.apps/docsite/src/app/(site)/_landing/hero/heroThemeContent.ts: clear.apps/docsite/src/lib/prefersReducedData.ts: clear.apps/docsite/src/__tests__/hero-reel-warm-up.test.tsx: clear.apps/docsite/src/__tests__/hero-theme-content.test.ts: clear.apps/docsite/src/__tests__/hero-reel-photos.test.tsx: clear.apps/docsite/e2e/home-reel-warm-up.spec.ts: clear.
Primary intent
Below 1024 px wide, where the hero reel does not advance by itself, the home page no longer loads the fonts and photos of the other four slides after load. It loads the two slides next to the current one when the visitor first moves a touch sideways on the reel or moves keyboard focus to its dots, and again after each change of slide.
No other template fits: this is a performance change in
apps/docsitewith no new capability and no public API.User or maintainer impact
Bytes for a cold first visit, on local production builds (
next build, thennext start) ofmainat d63c249 and of this branch. Headless Chromium 149, bytes on the wire from the DevTools protocol.A touch row is the row above it plus the requests that the touch starts. A scroll starts none. One swipe loads 273 KB: the slide after and the slide before the first one (6 photos and 6 font files, 212 KB), and after the swipe the next slide over (3 photos, 61 KB). Its fonts are the Butter fonts, which the themes card of the page loads.
The trade, measured. A swipe from the first slide to the second, 0.29 to 0.33 s from touch start to touch end. The downloads start 0.03 to 0.04 s after the touch starts, when it has moved 10 px sideways. Time from the change of slide to the arrival of the second slide's files, in two runs of each throttled case and one run with no throttle:
On
mainthe files are in the cache before the swipe in all three cases. The next swipes do better than the first: after each change of slide the page loads the next neighbor while the visitor looks at the new slide.Slow 4G, 0.37 s after the swipe ends:
mainon the left, this branch on the right. The branch shows the Matcha slide with the photos of the first slide and a fallback font. The photos are replaced 0.5 to 0.9 s after the swipe, and the font 1.4 to 1.7 s after it.Problem and solution fit
HeroReelProviderloads the fonts and photos of every slide at the first idle moment after load. It does that so that an auto-advance does not show a font flash or a photo that pops in. The effect does not ask whether the reel advances.Each delta maps to that problem:
hero/HeroThemeReel.tsx, the warm-up effecthero/HeroThemeReel.tsx,warmNeighborsOfgoTocalls it for the slide that a swipe or a dot moves to.lib/prefersReducedData.tswarmNeighborsOfreturns early when it is true.hero/HeroThemeReel.tsx,warmAssetsImagethesizesand thesrcsetof the card's<img>before thesrc, as the old effect did.hero/heroThemeContent.tsslideAssetsnames the fonts of one slide and the sources of its three photos: the samesrc,srcsetandsizesthat its cards render. The flat lists that the wide path loads are built from the same data and are the same as before.src/__tests__/hero-reel-warm-up.test.tsx,src/__tests__/hero-theme-content.test.ts,src/__tests__/hero-reel-photos.test.tsx,e2e/home-reel-warm-up.spec.tsThree choices that a reader can question:
goToloads the slides for a press. The handler reads:focus-visibleto tell the two apart.The reason for the wide path is a reel that advances by itself, and its condition is the width, as on
main: a wide screen with reduced motion still loads every slide.No tagalongs, and no change to what a wide screen loads.
The narrow path loads the file that the slide shows. The reel's photos load through the image optimizer, and the browser selects a width from the
srcsetand thesizesof each card's<img>.slideAssetsgives the warm-up those same sources, so the browser selects the same file for the warm-up'sImageand for the card. The network log of a 390 by 844 screen at 3x through two swipes (full log), after the first swipe:Through load and two swipes the page makes 15 requests for 15 photos, and requests no photo at a second width.
Authority
pnpm specs:for --diff origin/mainroutes no concern claim to the changed lines. The change edits an Effect, so I read the claims ofarchitecture:react-component-runtimethat govern one:goTo). No effect reacts to interaction state.spec:AST-033andarchitecture:knowledge-contractsare linked toapps/docsite/**. None of their claims covers when a page loads a font or a photo.mainthe reel's photos are smaller, and the saving is 334 KB.Change and evidence
Red, then green. The new browser test on a production build of
main:On the build of this branch the four tests pass. The numbers are the photos that the page requested for each of the five slides, in the first test.
On a build of this branch in which the warm-up gives an
Imageonly itssrc, and not thesizesand thesrcsetof the card, all four tests fail: the page asks for a neighbor's photos at 1080 px, where the browser selects 256 px for a card.No change at rest. First-screen screenshots of
mainand of this branch, with the first slide and with the second slide after a dot press and a wait for its files:Two captures of
mainat 1440 by 900 differ in the same way: 27 pixels, by at most 2 of 255.A wide screen loads the same files. At 1440 by 900 the page makes the same 135 requests before and after, and requests each of the 15 reel photos once, at the same widths. The total changes by 0.3 to 0.4 KB, the size of the new code. In one of four runs of the branch, Google Fonts answered the stylesheet of a template preview frame with a second URL for Figtree (one more request, 20 KB). The reel does not make that request.
Scope
Components: docsite home hero reel
Testing
src/__tests__/hero-reel-warm-up.test.tsx(new, 18 tests, jsdom). The provider, the swipe area and the dots (the realPagination) with a five-slide fixture, and a record of the fonts and photos that they ask the browser for. A photo is recorded with thesizesand thesrcsetthat itsImagehas when it gets itssrc.src/__tests__/hero-theme-content.test.ts(new, 6 tests). The real slides: the font list and the photo list are pinned to the 18 font entries and the 15 file names thatmainhas, in the same order, and each slide names its own three photos and the fonts of its own theme.src/__tests__/hero-reel-photos.test.tsx(2 new cases, 10 tests). For each slide,slideAssetsnames the sources that each of the two card layouts renders for that slide.e2e/home-reel-warm-up.spec.ts(new, 4 tests). The built page, with real touches sent through the DevTools protocol, a tap on a dot, and the Tab key, and a count of the requests for reel photos. Only a browser tells keyboard focus from the focus that a press gives. After a swipe and after a press on a dot, the test waits until the new slide draws its own photos. Each test then checks that the page requested no photo twice, and that it requested the photos of each loaded slide at the widths of the first slide's photos, which the browser selects with no load ahead. The second check is necessary: Chromium shows a wider file that it has in place of a request for the narrower one, so a count of requests does not find a load ahead of a file that is too wide.warmNeighborsOfwith its data-saving rule,goTo, the touch rule and its length, the focus rule of the dots, focus in the hero text, the font and photo lists, and thesizesand thesrcsetof a photo and their order before itssrc.pnpm review:pre --head HEADreports 0 findings.docsite-buildartifact, withCIset, which is how CI'sdocsite-browserjob runs it.Not tested:
:focus-visible,requestIdleCallbackwith the timer fallback thatmainhas, anddocument.fonts.load.