1.18.0 performance items: tests, the reference budget gate tightened (JS 195 kB, 404 without its exception, TTL check), docs (performance.md, AGENT.md, iapl-performance, module pages, api.md), changelog: what changes for an existing site

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 15:54:15 +01:00
co-authored by Claude Opus 5.5
parent d628839235
commit f0127ac1b8
35 changed files with 1154 additions and 288 deletions
+22 -16
View File
@@ -20,12 +20,15 @@ response on that profile (the 404 page is the exception, below).
| LCP image | `<Media priority>`: `fetchpriority="high"`, `loading="eager"` and a preload; everything else lazy with `sizes` | `priority` / `eager` / `sizes` per image (`MEDIA_SIZES`) |
| Image formats | `buildImagesConfig()`: AVIF and WebP, the width the screen needs, a 31-day cache, R2 allowed | `buildImagesConfig({ … })` ([media.md](./media.md)) |
| Upload limits | `buildOptimizeUploadHook()`: images over 1.5 MB or 2560 px wide are stopped; the editor may let the plugin shrink them (WebP, metadata dropped) | `maxImageBytes`, `maxImageWidth`, `quality` |
| Upload metadata | every JPEG and PNG that passes the limits loses its metadata (camera, date, GPS, comments) without re-encoding — pixels and colour profile byte for byte; an EXIF "rotate" is applied once (JPEG q92) | `buildOptimizeUploadHook({ stripMetadata: false })`; the building block `stripImageMetadata(buffer, mime)` |
| No layout shift from images | width and height always from the document; a blur placeholder and the dominant colour (`buildMediaPlaceholderHook`) | `placeholderColor` |
| Embeds | `<YouTubeEmbed>`: a picture and a button; the iframe only after a click, from youtube-nocookie.com | `poster` |
| Client JavaScript | small client leaves; since 1.18.0 a page ships only the client components it renders (the `/client` barrels are no longer one client boundary) and the lightbox viewer loads on the first open | — |
| Client JavaScript | small client leaves; a page ships only the client components it renders (the `/client` barrels are no longer one client boundary); the lightbox viewer loads on the first open; the form engine and the Turnstile widget load only on pages that show a form (`BuilderForm` / `Turnstile` from `/client` are lazy wrappers, the server renders the whole form) — 6–9 KB gzip less JavaScript on every other page of the reference site (webpack −8.8, Turbopack −6.1) | `@intecion/ipal-kit/client/eager` → `<RenderForm Form={BuilderForm}>` |
| Turnstile | its 73 px are kept free before Cloudflare draws the widget: the form does not jump | `turnstileReserveHeight={0}` (an invisible widget) |
| Third parties before consent | none besides Google's tag in Consent Mode `advanced` (all signals denied); Meta, LinkedIn, TikTok and Clarity wait for consent; Turnstile only on a form's last step | `analytics={{ consentMode: 'basic' }}` — no request to Google before consent; `analytics={{ defer: true }}` — the tag after the first interaction |
| Fonts | the reference layout uses `next/font` (self-hosted, `display: 'swap'`, fallback metrics against layout shift) | the project's own fonts |
| Motion | the token durations (`duration-fast`, `-base`, `-slow`) are 0 ms with `prefers-reduced-motion: reduce`; the cookie banner, its switches and the cookie button stop their transitions too | `motion-reduce:` classes |
| Fonts | the reference layout (and every new site from `iapl create`) uses `next/font` (self-hosted, `display: 'swap'`, fallback metrics against layout shift) and does not preload the heading font: the stylesheet and the hero get the first round trips (phone: first paint and LCP 36–52 ms sooner) | the project's own fonts; `preload: true` on the heading font |
| Motion | the token durations (`duration-fast`, `-base`, `-slow`) are 0 ms with `prefers-reduced-motion: reduce`; the cookie banner, its switches and the cookie button stop their transitions too; a background video (`<Media videoMode="background">`) is paused for those visitors; the card hover fades a shadow layer (`opacity`, compositor-only) instead of animating `box-shadow` | `motion-reduce:` classes; `<Media pauseForReducedMotion={false}>`; `CARD_INTERACTIVE_SHADOW_CLASS` (the 1.17 hover) |
| 404 | the lazy 404 (`createNotFoundPage({ load })`) keeps its content's height with `placeholder` — the reference site sets it (phone: CLS 0.319 → 0, LCP 2.5 → 1.9 s) | the placeholder's height follows your 404 content |
| Admin only | Payload's colour-scheme client hints only on `/admin`, so a public page is requested once | `withSecurityConfig(…, { adminClientHints: false })` |
## 2. What a project must do
@@ -43,16 +46,18 @@ Every row is something the plugin cannot decide for you. `iapl-doctor --only per
**Elements** ([web.dev/articles/cls](https://web.dev/articles/cls))
- Images through `Media` (dimensions, `sizes`, lazy below the fold, never lazy for the LCP image —
[web.dev/articles/lcp-lazy-loading](https://web.dev/articles/lcp-lazy-loading)).
- Content that arrives after the first paint reserves its space. The lazy 404 is the plugin's own case:
`createNotFoundPage(content, { load, placeholder: <div style={{ minHeight: '36rem' }} /> })` with the height of your
404 content keeps the footer still.
- Content that arrives after the first paint reserves its space. The lazy 404 is the plugin's own case: the
reference `not-found.tsx` passes `placeholder: <div aria-hidden style={{ minHeight: 'max(290px, calc(212px + 11.5vw))' }} />`
— its 404 content's height, measured from 360 to 1920 px wide. Measure yours the same way when the 404 content
changes (the footer must not move when it arrives).
- Maps, videos and widgets behind a click: a picture and a button ([web.dev/articles/third-party-facades](https://web.dev/articles/third-party-facades)).
**Fonts** ([web.dev/articles/font-best-practices](https://web.dev/articles/font-best-practices),
[nextjs.org/docs/app/getting-started/fonts](https://nextjs.org/docs/app/getting-started/fonts))
- `next/font` only, at most two families, variable fonts, `subsets: ['latin', 'latin-ext']` for Polish,
`display: 'swap'`. Every subset of every family is a preloaded file: two variable families with two subsets are
four files (the reference site: 209 KB). A third family or a second weight file is the first thing to cut.
four files (the reference site: 209 KB). The heading font gets `preload: false` (the starter's default): its files
still come, after the stylesheet and the hero. A third family or a second weight file is the first thing to cut.
**Animations** ([web.dev/articles/animations-guide](https://web.dev/articles/animations-guide),
[web.dev/articles/prefers-reduced-motion](https://web.dev/articles/prefers-reduced-motion))
@@ -145,24 +150,24 @@ Measured on the reference site after a full test run (MongoDB; average record wi
| What | Grows with | What the plugin does (1.18.0) | What the project decides |
|---|---|---|---|
| Consent log (`consent-records`) | one record per banner choice | deleted after `retentionDays` (default 1095 — three years, the proof-of-consent period); the purge runs at most once a day, after a new record | `consentLog: { retentionDays }` |
| Statistics (`stats-visits`, opt-in) | one record per visit | deleted after `retentionDays` (default 90), same purge | `stats: { retentionDays }` |
| Consent log (`consent-records`) | one record per banner choice | deleted after `retentionDays` (default 1095 — three years, the proof-of-consent period): on MongoDB by a TTL index (`iapl_ttl` on the hidden `iaplTtlFrom`, kept at the current retention at every start), also on a quiet site; everywhere also by the purge after a new record (at most once a day) | `consentLog: { retentionDays, ttlIndex: false }` |
| Statistics (`stats-visits`, opt-in) | one record per visit | deleted after `retentionDays` (default 90) since the visit's last page view: TTL index on MongoDB, the same purge | `stats: { retentionDays, ttlIndex: false }` |
| Form submissions | one per sent form (files are never stored: they go out by e-mail) | **kept** until deleted in the panel — unless `forms: { submissionRetentionDays }` is set (1.18.0), then deleted after that many days, once a day after a new submission | the retention: personal data, a client decision (AGENTS.md → Project decisions) |
| Versions and drafts | every save | the plugin turns versions on nowhere; Payload keeps 100 per document by default (`maxPerDoc`, `max` for globals) | a lower limit where you turn versions on: `versions: { maxPerDoc: 20 }`; never `0` (unlimited) |
| Versions and drafts | every save | the plugin turns versions on nowhere; when a project turns them on for one of the plugin's collections or globals (overrides) without a limit, it keeps 20 per document (Payload's default is 100) | your own limit wins (`max`, `maxPerDoc`); on your own collections `versions: { maxPerDoc: 20 }` (the doctor's `growth-versions-config` hint); never `0` |
| `payload-kv` | 2FA attempt counters (one per staff account), the mail service state (one per host), enrolment nonces | expired mail-service nonces are swept (at most once a day, when the next enrolment starts); counters and state are bounded by accounts and hosts | — |
| Cookie review (opt-in) | distinct cookie names | upserted by name; a cookie that disappears is marked `gone`, not deleted (the history of what the site set) | delete old `gone` rows in the panel when the client agrees |
| `payload-preferences`, `payload-locked-documents`, `payload-jobs` | panel users, open documents, queued jobs | Payload removes them with the user, on save, and on completion (`deleteJobOnComplete`); the plugin queues no jobs | — |
| Media | uploads | Payload deletes the files (and R2 objects) with the document; nothing deletes media nobody uses | review `growth-media` findings in the panel |
| Media | uploads | Payload deletes the files (and R2 objects) with the document; nothing deletes media by itself. `iapl({ unusedMedia: true })` shows above the Media list how many files no page, entry or setting uses (by id, or by file name inside a text) and links to Payload's list filtered to them; the editor checks and deletes them there | turn it on (then `pnpm generate:importmap`); the doctor's `growth-media` counts them either way |
| `.next/cache/images` | each image × width × format (AVIF + WebP) | kept 31 days per variant (`minimumCacheTTL`); Next caps nothing by size | no persistent volume on `.next` in Coolify: every deploy starts empty |
| ISR output | pages × languages | rewritten in place on each revalidation | — |
| Logs | — | the plugin writes no files; it logs to stdout (Coolify keeps the container's log) | Coolify's log retention |
**Postgres and SQLite:** the same purges (one `DELETE … WHERE created_at < …`); no TTL indexes; the doctor reports
counts but not sizes. A consent log without its migration records nothing and so never purges.
**Postgres and SQLite:** the same purges (one `DELETE … WHERE created_at < …`); no TTL index and no `iaplTtlFrom`
column (no migration); the doctor reports counts but not sizes. A consent log without its migration records nothing and so never purges.
**What a project schedules:** nothing for the plugin's own logs — the purges run inside the site. A site that gets
no new consent records (or submissions) for a long time keeps the old ones until the next one comes; the doctor's
`growth-retention` rule says so. Database backups are the hosting's job (Coolify → the MongoDB resource → Backups).
**What a project schedules:** nothing for the plugin's own logs — on MongoDB the TTL indexes delete by themselves,
elsewhere the purges run inside the site after a new record. A SQL site that gets no new consent records (or
submissions) for a long time keeps the old ones until the next one comes; the doctor's `growth-retention` rule says so. Database backups are the hosting's job (Coolify → the MongoDB resource → Backups).
**How to check:** `pnpm exec iapl-doctor --deep --only growth` (or `--url` with `IAPL_DOCTOR_TOKEN`): document
counts, sizes (MongoDB), the oldest record, versions per collection and global, expired KV entries, media no
@@ -181,6 +186,7 @@ document points at; and on the machine it runs on, the image cache and the local
| `growth-submissions` | deep | form submissions kept without a retention (info; a warning when the oldest is over `submissionDays`) |
| `growth-kv` | deep | more than `expiredKv` expired entries in `payload-kv` |
| `growth-media` | deep | media nothing points at (info; a warning over `orphanedMedia`). Counted from the first 5000 documents |
| `growth-versions-config` | static | a collection or global of the project turns versions on without `maxPerDoc` / `max` (info: Payload keeps 100) |
| `growth-disk` | static | `.next/cache/images` over `imageCacheMB`, the local `media/` folder over `uploadsMB` (info) |
None of these rules deletes anything; the plugin never deletes media or submissions by itself.