Skip to content
SprecherEast
Issue 923

chore: measure today's page speed, page weight and database work as the baseline for the budgets

Back to our plan
Open
cifrontendtoolingtech-debtpriority: high

We can't set budgets, or tell whether a change made things slower, without knowing where we stand today. This measures the public pages (and the admin, second) the same way the budget checks will, and saves the numbers in the repository so every budget is set from them.

Problem

There is no measurement of how fast the pages are, how much JavaScript and how many bytes they send, or how many database queries each one makes. Budgets set without a baseline are guesses, and guessed budgets either fire all the time or never.

Proposed fix

  1. Pages to measure. One of each public page type, from docs/reference/routes.md: home, posts list, one post, events list, one event, an events category, FAQ, resources, one CMS page, search. Admin second: sign-in, one collection list, one edit view. Keep the list in one file the later checks read, so every tool measures the same pages.
  2. Where. Two places, kept apart in the results:
    • CI, where the budgets will fire: the production build started by e2e/serve.mjs (fresh SQLite, production build), on a GitHub-hosted runner. Seed it with representative content: enough posts and events to fill the lists, rich text with blocks, and a set of sample images (free to use, made for testing, not real neighbors' photos). Extend the existing seed; don't write a second one.
    • Production, for the real picture: the live site, measured from outside the server, read-only.
  3. What.
    • Lab page speed, mobile preset: Largest Contentful Paint, Cumulative Layout Shift, Total Blocking Time, total bytes, JavaScript bytes, image bytes, request count. Use the Lighthouse version the page-speed budget issue evaluates, median of several runs per page; record the run count and the spread, because runners are noisy.
    • Server time: time to first byte for a cached page and for the first visit after a save (the page re-renders), on production.
    • Client JavaScript per route from the native next analyze --output and next analyze export (Next 16.4; next build no longer prints sizes).
    • Database work per page render: query count and the slowest queries. Native route: the SQLite adapter takes a Drizzle logger (sqliteAdapter({ logger })), so a logger that counts and records queries, switched on only by an environment variable and never in production, gives the count without new packages. Time each render from the server side.
  4. Save it. A committed baseline file (machine-readable, one entry per page and metric, with the tool versions, run count, runner type and date of measurement), plus a short human summary posted on this issue. The page-speed, bundle and query budgets read this file. Put the measuring script where docs/architecture/ says scripts go.

Tool evaluation: record on this issue, once, for each tool used here that the budget issues have not already evaluated: maintained? free for our use? runs in our setup? what data it sends out? fits native first?

Acceptance criteria

  • Not done: One page list file, read by the baseline script and later by the budget checks
  • Not done: The seed covers lists, rich text and images, extended from the existing seed
  • Not done: A committed baseline file with CI and production numbers kept apart, tool versions, run count and spread
  • Not done: Query count per page for every page on the list, from the adapter's logger, off unless its environment variable is set
  • Not done: A summary on this issue: the slowest pages, the heaviest pages, the pages with the most queries
  • Not done: Nothing changed on the server; production was only read

Files likely touched

e2e/serve.mjs or the seed under src/endpoints/seed/ (extended, not copied), src/payload.config.ts (the logger, behind an environment variable), a new measuring script and baseline file, docs/project.md (one line on how to re-run it).

Must not touch

Production configuration (.env.local, Caddy, PM2). The end-to-end tests' own flows and fixtures beyond what the seed needs.

Open questions

  • Is real content copied from production allowed in the CI seed? Default: no, sample content only, since the repo is public.
See it on GitHub, opens in a new tab