Repository navigation
Load home highlights behind the loading screen - #576
Merged
Merged
Conversation
The home page fetched its highlights alongside the restaurant list and only rendered the section once they arrived, so the location skeletons already on screen jumped about 300px down when they landed (CLS 0.226 on mobile). Reserving skeleton space instead would make a restaurant without highlights jump the other way, so the page has to know before it renders. BrandProvider now fetches the highlights in parallel with the brand, behind the loading screen it already shows, and hands them out through useHighlights. The home screen only loads restaurants itself, and pull-to-refresh no longer refetches highlights. fetchHighlights moves to its own api/highlights.ts, which jest.setup mocks so suites that queue fetch responses are not handed an extra request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The home page fetched its highlights alongside the restaurant list and only rendered the section once they arrived. The location skeletons were already on screen, so they jumped about 300 px down when the highlights landed: CLS 0.226 in Lighthouse, 0.275 in a throttled Moto G4 trace, all from that one shift.
Reserving skeleton space for the highlights fixes it for a restaurant that has them (0.005) and breaks one that doesn't, which then jumps the other way (0.258 mobile, 0.134 desktop). The page has to know before it renders, so
BrandProvidernow fetches the highlights in parallel with the brand, behind the loading screen it already shows, and hands them out throughuseHighlights.Follow-up to #574 and #575.
Related issue
None.
Scope
Changes
fetchHighlightsmoves to its ownapi/highlights.ts(home was its only caller).jest.setup.tsmocks it to[], because a real call from the provider took a response other suites had queued onfetchfor their own requests (222 failures across 9 suites before this)./api/brand, so it adds no round trip.CLS from a layout-shift trace (throttled Moto G4, 4x CPU, and a 1350x940 desktop):
The 0.037 left on desktop with no highlights is the footer moving as location skeletons turn into slightly taller cards. Same on
main, under 0.1.Lighthouse 13.6.0, mobile preset, median of 3, against
mainafter #575:No JS was added, so the TBT difference is run-to-run variance.
Testing
OpenRestoApi.Testspass locally (no API changes)npm run check,tsc --noEmit,check:doc-links,npm testandnpm run test:android(4161 tests each),expo export --platform webMigrations
Checklist