# Performance: before and after the modernisation phase (idea 2)

Measured 2026-11-17 by the Performance and SEO role with `php scripts/qa/perf.php` (headless Chrome,
1440x900, **browser cache disabled**, local `php artisan serve` on port 8104). Raw data:
`docs/qa/perf-baseline.json` (before) and `docs/qa/perf-after.json` (after).

- **Initial** = bytes transferred until the load event plus 2 s, without scrolling (lazy images below the
  fold not included). **Scrolled** = after scrolling to the bottom of the page and waiting 2 s (every lazy
  image fetched).
- Bytes are Chrome's `encodedDataLength` (what went over the wire). The local PHP server does **not
  compress**, so HTML/CSS/JS are counted uncompressed here; on the real server `public/.htaccess` enables
  Brotli/gzip, which shrinks those text files by roughly 75-85%. Image, font and video bytes are the same
  locally and in production.
- The baseline was taken at the very start of this role's work. The Site and Products roles were working
  at the same time, so "after" contains all three roles' changes. Images (and the image preload) are this
  role's work; the font reduction is the Site role's (idea 1, two families); HTML and CSS growth includes
  their new sections (comparison tables, FAQ, mobile bar) as well as the `<picture>` markup.

## Per page (KB)

| Page | Initial before | Initial after | Change | Scrolled before | Scrolled after | Change | Images (scrolled) before -> after | LCP before -> after |
|---|---:|---:|---:|---:|---:|---:|---|---|
| home | 974 | 509 | -48% | 1345 | 805 | -40% | 637 -> 374 | 364 -> 416 ms |
| about | 582 | 259 | -56% | 640 | 288 | -55% | 445 -> 122 | 304 -> 216 ms |
| pricing | 668 | 387 | -42% | 725 | 438 | -40% | 350 -> 103 | 476 -> 436 ms |
| contact | 436 | 208 | -52% | 494 | 237 | -52% | 270 -> 62 | 376 -> 252 ms |
| idms-idealers-management-system | 495 | 377 | -24% | 690 | 492 | -29% | 317 -> 181 | 368 -> 288 ms |
| inventory-management | 682 | 449 | -34% | 780 | 506 | -35% | 437 -> 208 | 420 -> 444 ms |
| leads-center | 566 | 435 | -23% | 670 | 495 | -26% | 325 -> 193 | 320 -> 416 ms |
| website | 971 | 653 | -33% | 1206 | 758 | -37% | 855 -> 450 | 352 -> 220 ms |
| marketing-tools | 706 | 392 | -44% | 921 | 462 | -50% | 496 -> 147 | 376 -> 260 ms |
| crm-system | 637 | 388 | -39% | 694 | 417 | -40% | 355 -> 123 | 296 -> 352 ms |
| design-studio-tool | 807 | 533 | -34% | 963 | 633 | -34% | 496 -> 262 | 416 -> 264 ms |
| request-demo | 377 | 201 | -47% | 434 | 230 | -47% | 220 -> 63 | 332 -> 280 ms |
| talk-to-sales | 321 | 214 | -33% | 321 | 214 | -33% | 166 -> 51 | 296 -> 236 ms |
| privacy-policy | 237 | 213 | -10% | 295 | 242 | -18% | 104 -> 42 | 264 -> 184 ms |
| terms-condition | 210 | 185 | -12% | 267 | 214 | -20% | 104 -> 42 | 148 -> 292 ms |
| **All 15 pages** | **8,667** | **5,401** | **-38%** | **10,444** | **6,429** | **-38%** | **5,576 -> 2,422** | median 352 -> 280 ms |

Requests (all 15 pages, scrolled): 369 before, 314 after.

## By resource type, all 15 pages (KB)

| Type | Initial before | Initial after | Change | Scrolled before | Scrolled after | Change |
|---|---:|---:|---:|---:|---:|---:|
| Images | 4,046 | 1,640 | **-59%** | 5,576 | 2,422 | **-57%** |
| Fonts | 2,167 | 1,067 | -51% | 2,167 | 1,067 | -51% |
| HTML (uncompressed) | 662 | 809 | +22% | 662 | 809 | +22% |
| CSS (uncompressed) | 1,636 | 1,700 | +4% | 1,636 | 1,700 | +4% |
| JS (uncompressed) | 156 | 184 | +18% | 321 | 350 | +9% |
| Video | 0 | 0 | - | 0 | 0 | - |
| **Total** | **8,667** | **5,401** | **-38%** | **10,444** | **6,429** | **-38%** |

## What improved

- **Images: -57% across the site** (5.4 MB -> 2.4 MB with every image loaded; -59% in the first view).
  `php artisan site:images` made AVIF and WebP variants of 133 of the 153 raster images (20 icons under
  4 KB / 120 px were left alone); `<x-media.img>` serves them through `<picture>`, and lazy images use
  `sizes="auto"`, so a 300 px-wide illustration now loads its 480 w AVIF instead of an 800-1,290 px PNG.
  Examples: about team photo `about26.png` 264 KB -> 59 KB, contact `3d3.png` 104 KB -> 11 KB (480 w AVIF),
  home hero `bkhero.webp` 158 KB -> 104 KB, footer background 33 KB -> 7 KB (every page).
- **Promo video: 0 bytes before play** on all six pages that offer it (home, about, contact, request-demo,
  talk-to-sales, IDMS), both before and after (`php scripts/qa/video.php`); pressing play loads the
  9.4 MB file. This was already correct in the rebuild and stays so.
- Fonts -51% (Site role, idea 1).
- No duplicate image downloads: the home preload is the same AVIF file the hero's `image-set()` picks.

## What did not improve, or not yet

- **LCP** on localhost moves between 150 and 480 ms in both runs; with no network latency these
  differences are noise, so no LCP gain is claimed from this local test. Lighthouse's simulated mobile
  numbers (below) are the better guide.
- **Product page hero backgrounds** (inventory, leads, website, marketing, CRM, IDMS, design studio,
  pricing) are still the original WebP files: they live in the Products role's CSS, which had not switched
  to `image-set()` at the time of this run (list and paths in `docs/handoff/perf-backgrounds.md`). Most are
  5-10 KB already, so the remaining gain is small, except design studio (82 KB -> 37 KB).
- HTML grew 22% (new sections from ideas 3 and 5 plus `<picture>`/`<source>` markup); compressed on the
  real server this is a few KB per page.
- Text compression cannot be measured locally (the PHP dev server sends no gzip/Brotli); Lighthouse flags
  it for that reason only.

## Image quality choice

AVIF quality 50 (speed 6) and WebP quality 80, chosen by converting the 3D illustration `3d6.png` (alpha),
the dark photo collage `bkhero.webp`, the logo `pp.jpg`, the people cut-out `about26.png` and the device
frame `laptop-macbook-black.png` at AVIF 40/50/60 and WebP 75/82 and viewing them side by side on a
checkerboard: at AVIF 50 no banding on the 3D gradients, transparency intact, no colour shift; AVIF 40
began to soften edges on the cut-outs for a 10-20% size gain, so 50 was kept. Any variant that is not
smaller than its source is discarded (this happens for several already-small WebP backgrounds).

## Lighthouse (after only)

Lighthouse 12.8.2 via `npx -y lighthouse@12.8.2` (no global install), default mobile profile with
simulated throttling, against the local server. It was not run before the changes (the baseline above was
captured with the Chrome script only), so these numbers have no "before".

| Page | Performance | Accessibility | Best practices | SEO | FCP | LCP | TBT | CLS | Total weight |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| Home | 92 | 100 | 100 | 92 | 2.0 s | 3.2 s | 0 ms | 0 | 396 KiB |
| Pricing | 86 | 96 | 100 | 100 | 2.9 s | 3.5 s | 0 ms | 0.006 | 408 KiB |

Audits passed: modern image formats, properly sized images, offscreen images, unsized images, render-blocking
resources. Remaining flags: text compression (local server only, see above); home SEO "links do not have
descriptive text" ("Read More" links, content owned by the Site role); pricing accessibility, colour contrast
of the plan period text "/ Per Month" (`.p-plan__period`, Products role).

## How to re-run

```
php artisan serve --port=8104
php scripts/qa/perf.php --out=perf-latest.json      # all 15 pages, ~2 minutes
php scripts/qa/video.php                             # video bytes before/after play
php artisan site:images                              # after adding images to public/media
```

---

## Dark redesign (QA lead, 2026-11-18)

Same script and settings: `php scripts/qa/perf.php --base=http://127.0.0.1:8105 --out=perf-dark.json --label=dark-redesign` (1440x900, cache disabled, local `php artisan serve`, no compression). Compared with the last run of the modernisation phase (`perf-final.json`, final QA). Raw data: `docs/qa/perf-dark.json`.

| Page | Initial before | Initial now | Change | Scrolled before | Scrolled now | Change | Requests (initial) |
|---|---:|---:|---:|---:|---:|---:|---|
| home | 509 | 273 | -46% | 805 | 459 | -42% | 29 -> 11 |
| about | 259 | 228 | -11% | 288 | 245 | -14% | 16 -> 12 |
| pricing | 387 | 259 | -33% | 438 | 296 | -32% | 16 -> 13 |
| contact | 208 | 191 | -8% | 237 | 206 | -13% | 15 -> 12 |
| idms-idealers-management-system | 381 | 215 | -43% | 496 | 339 | -31% | 21 -> 12 |
| inventory-management | 417 | 293 | -29% | 474 | 307 | -35% | 20 -> 15 |
| leads-center | 405 | 241 | -40% | 465 | 325 | -30% | 22 -> 17 |
| website | 573 | 301 | -47% | 676 | 500 | -25% | 24 -> 14 |
| marketing-tools | 384 | 227 | -40% | 454 | 280 | -38% | 18 -> 13 |
| crm-system | 376 | 202 | -46% | 405 | 245 | -39% | 19 -> 12 |
| design-studio-tool | 492 | 366 | -25% | 592 | 442 | -25% | 17 -> 13 |
| request-demo | 201 | 173 | -13% | 230 | 188 | -18% | 15 -> 12 |
| talk-to-sales | 214 | 158 | -26% | 214 | 172 | -19% | 15 -> 11 |
| privacy-policy | 213 | 204 | -4% | 242 | 218 | -9% | 13 -> 11 |
| terms-condition | 185 | 176 | -4% | 214 | 191 | -10% | 12 -> 10 |
| **All 15 pages** | **5,210** | **3,514** | **-32%** | **6,237** | **4,420** | **-29%** | |

- Home's total transfer is well under the budget in the brief (459 KB scrolled vs 805 KB). The weight fell mainly because the dark pages no longer load the light-design hero backgrounds, the PNG device frames and the per-page product CSS (about 6,700 lines down to about 390), and the living light is pure CSS.
- 0 video bytes before play on every page. The only "failed" requests are the three idealers.app frames, refused by idealers.app's own policy outside idealers.net (expected).
- Local LCP (500-1,600 ms) is noise on localhost without latency; see Lighthouse below.

### Scripting and rendering cost while scrolling (4x CPU throttling)

Headless Chrome, CPU throttled 4x, page scrolled from top to bottom with real wheel events (120 px every 33 ms), then 3 s idle at the bottom; long tasks from a `PerformanceObserver`, frame intervals from `requestAnimationFrame` (headless renders up to 120 frames/s, so a smooth frame is ~8 ms).

| Page | Width | Long tasks (blocking time) | Frame p50 / p95 | Frames > 50 ms / > 100 ms |
|---|---|---|---|---|
| home | 390 | 4 (73 ms) | 8 / 25 ms | 11 / 0 of 833 |
| website | 390 | 0 | 8 / 17 ms | 2 / 0 of 661 |
| home | 1440 | 7 (102 ms) | 8 / 33 ms | 15 / 2 of 862 |
| design-studio-tool | 1440 | 4 (132 ms) | 8 / 25 ms | 6 / 1 of 717 |

Verdict: scrolling stays smooth on a 4x-throttled profile; the occasional long frames fall on scene boundaries (a pinned scene starting or ending) and when images first decode. The scroll handler itself is cheap (script evaluation 65 ms over the whole home load in Lighthouse).

**Living light on phones (fixed).** Idle at the top of home at 390 px and 4x CPU, the drifting light ran at 61 frames/s with a 41 ms 95th-percentile frame and 3 long tasks in 4 s; the cost was a 40 px `filter: blur()` on three moving 400-500 px blobs. Phones now drop the blur (the blobs are radial gradients that already fade out; screenshots compared, the light looks the same, slightly more defined): **91 frames/s, p95 17 ms, 0 long tasks.** Desktop keeps the blur (82 frames/s, p95 25 ms at 4x). `resources/css/site/motion.css`.

### Lighthouse (dark redesign)

Lighthouse 12.8.2 via `npx -y lighthouse@12.8.2`, default mobile profile, simulated throttling, local server.

| Page | Performance | Accessibility | Best practices | SEO | FCP | LCP | TBT | CLS | Total weight |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| Home | 94 (was 92) | 96 (was 100) | 100 | 100 (was 92) | 1.6 s | 2.2 s | 230 ms (was 0) | 0 | 295 KiB (was 396) |
| Pricing | 92 (was 86) | 96 (was 96) | 100 | 100 | 2.4 s | 2.9 s | 0 ms | 0 | 280 KiB (was 408) |

- **TBT 230 ms on home** is one 263 ms (simulated) task at start-up: the style and layout pass when the motion kit switches the page into its pinned layout (`html.motion`, scene heights) and splits the statements into words. Script evaluation is only 65 ms; most main-thread time is style/layout (743 ms) and rendering (593 ms) under 4x simulation. Acceptable for this kind of page, but it is the price of the scroll scenes.
- **Accessibility 96** on both: Lighthouse reads the lighting statements before they are scrolled into view, when unlit words are at 30 % opacity (#4c5352 on #050d0b, 2.49:1) and the strength lines at 25 %. That is the approved word-by-word effect; every word is at full colour once it is in view (our contrast audit, which scrolls, measures 0 failures), and with reduced motion or JavaScript off everything is lit. Recorded as a known, deliberate finding.
- Remaining flags as before: text compression and cache lifetimes (local server only), some unused CSS (22-57 KiB).
