Skip to content

perf(jobs): render the public listing's rows on the server (LCP 94s → 3s) - #783

Merged
thinkclay merged 1 commit into
mainfrom
feat/774-jobs-first-paint
Sep 17, 2026
Merged

thinkclay merged 1 commit into
mainfrom
feat/774-jobs-first-paint

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

What

The public /jobs listing now renders its rows on the server. Part of #774 — the LCP half. The CLS half turned out to be a different bug: #782.

  • Route loader fetches both lists — published jobs (the same /v1/jobs?status=published request the screen's hook makes with an empty search) and the external feed — and hands them to DiscoverJobsScreen as react-query initialData. One tree, not two: the server renders rows from the loader data, the first client render reads the same data through useLoaderData, and only after hydration does react-query own it. initialData counts as fresh for the 5-minute staleTime, so the client does not refetch what it was just handed. /jobs/<slug> has rendered this way since Indexed public job pages redirect anonymous visitors to /auth #734.
  • Skeleton shaped like the cards it stands in for (no media block, fixed 176px height, list minHeight reserved). It now only shows where there is no loader — native, and a non-empty search.
  • No more anonymous 401s. SaveJobButton's follow-status lookup (one per card, 10 per load) and the right rail's soft-skills lookup are gated on a session, like useUserApplications already was. An anonymous load of /jobs now makes two API calls after hydration (filter options and — still — nothing else), down from thirteen.
  • fetchPublicJobs no longer drops slug-less rows; the route filters with hasSlug where it builds the ItemList, since the cards link by id.

Numbers

Local, production export (expo export) served with expo serve, Lighthouse 12.8 with Playwright's Chrome, three runs each, median. The mobile row is Lighthouse's default preset and what .lighthouserc.json / the nightly measure; it reproduces the CI baseline in #774 to the millisecond.

preset perf FCP LCP SI TBT CLS
main mobile 0.10 2708 94 328 33 794 1682 0.981
this PR mobile 0.27 3155 3 155 38 139 1602 0.981
this PR desktop 0.76 624 624 — 331 0.002

LCP is now the same paint as FCP: the rows are in the HTML. Server HTML for /jobs went from 0 job cards and a skeleton to 11 cards and no skeleton (curl + grep 'data-testid="job-card"').

The CLS is a different bug

CLS did not move on mobile, and the trace says why: the one 0.98 shift is at +744ms, and it is the whole list moving from y=109 to y=16 while the search header above it disappears. That is the server's desktop layout (useResponsive's fixed 1280×900 server snapshot) being replaced by the mobile layout on hydration — on every SSR page, at every phone width, regardless of what the list does. It also means React regenerates the tree on every mobile load, which is the #681 symptom. On the desktop preset CLS is 0.002. Filed as #782 with the trace evidence; it needs @scaffald/ui to accept a per-request server snapshot, so it is not this PR.

The .lighthouserc.json ratchet (acceptance box 5) waits for that fix too — setting a mobile CLS budget of 0.98 would be recording the bug, not a budget.

Verification

  • 3 new tests: usePublishedJobs / useExternalJobs render seeded rows on the first render and do not call the client while fresh; unseeded queries still fetch. Typecheck green for scf-core and scaffald-app; lint clean; pnpm prepush green.
  • Dev server, anonymous, 1440 wide: server HTML carries the 11 cards; a fresh load makes exactly two API requests after hydration (/jobs/external/filter-options, and /profiles/skills/soft is gone); no hydration errors at desktop width.
  • Layout-shift probe (PerformanceObserver, real Chromium, 1350 wide, with and without 4× CPU throttling): one 0.002 shift from web fonts, nothing else.

🤖 Generated with Claude Code

…the skeleton moving the page

Part of #774 (the LCP half; the CLS half is #782).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant