fix(perf): BIT-28145 follow-up — wire sanitizer tests, defer non-critical scripts #48

Merged
spark merged 1 commits from fix/BIT-28145-tbt-followup into main 2026-08-07 10:33:26 +01:00
Owner

Summary

  • Post-merge Lighthouse re-verification of PR #47 confirms the article TBT regression is resolved: 7416ms -> 0-348ms, Performance 60 -> 99 median (5 runs + home control, results in docs/PERFORMANCE_BASELINE.md "Deploy & Re-Verification — 2026-08-07").
  • This follow-up closes a test-wiring gap found during that verification and adds margin above the 90 threshold:
    • bridge/package.json: sanitize-html.test.ts (added in the original fix, commit ee84059) was never added to the test/test:coverage npm scripts, so PR #47's claim of "28 bridge sanitizer tests pass" was not actually exercised by npm test. Fixed.
    • Defer mobile-menu and share-button click handlers to requestIdleCallback (institutional/sports headers, ArticleShareBar).
    • Split Base.astro's theme-flash-prevention script into a minimal inline snippet (must run before paint) and the deferred click-handler logic.
    • bridge /articles/:slug/related accepts optional ?category_id= to skip a redundant WP post-by-slug fetch.

Test plan

  • 58 bridge tests pass (npm test, now actually including the 28 sanitizer tests)
  • 47 frontend tests pass
  • bridge tsc --noEmit clean
  • Astro build succeeds
  • Lighthouse re-verified live on newsproject.bitreport.pt article page: 5 runs, median Performance 99, TBT 0-348ms (see docs/PERFORMANCE_BASELINE.md)

Closes BIT-28145 acceptance criteria (root cause documented, fix implemented + deployed, Lighthouse Performance >=90 confirmed on live article pages).

## Summary - Post-merge Lighthouse re-verification of PR #47 confirms the article TBT regression is resolved: 7416ms -> 0-348ms, Performance 60 -> 99 median (5 runs + home control, results in docs/PERFORMANCE_BASELINE.md "Deploy & Re-Verification — 2026-08-07"). - This follow-up closes a test-wiring gap found during that verification and adds margin above the 90 threshold: - `bridge/package.json`: `sanitize-html.test.ts` (added in the original fix, commit ee84059) was never added to the `test`/`test:coverage` npm scripts, so PR #47's claim of "28 bridge sanitizer tests pass" was not actually exercised by `npm test`. Fixed. - Defer mobile-menu and share-button click handlers to `requestIdleCallback` (institutional/sports headers, `ArticleShareBar`). - Split `Base.astro`'s theme-flash-prevention script into a minimal inline snippet (must run before paint) and the deferred click-handler logic. - `bridge` `/articles/:slug/related` accepts optional `?category_id=` to skip a redundant WP post-by-slug fetch. ## Test plan - [x] 58 bridge tests pass (`npm test`, now actually including the 28 sanitizer tests) - [x] 47 frontend tests pass - [x] bridge `tsc --noEmit` clean - [x] Astro build succeeds - [x] Lighthouse re-verified live on newsproject.bitreport.pt article page: 5 runs, median Performance 99, TBT 0-348ms (see docs/PERFORMANCE_BASELINE.md) Closes BIT-28145 acceptance criteria (root cause documented, fix implemented + deployed, Lighthouse Performance >=90 confirmed on live article pages).
spark added 1 commit 2026-08-07 10:20:20 +01:00
fix(perf): BIT-28145 follow-up — wire sanitizer tests into npm test, defer non-critical scripts
Tests / writer-pipeline tests (push) Successful in 1m30s
Tests / frontend lib tests (pull_request) Successful in 1m22s
Tests / bridge tests (push) Successful in 1m30s
Tests / frontend lib tests (push) Successful in 1m30s
Tests / bridge tests (pull_request) Successful in 1m23s
Tests / writer-pipeline tests (pull_request) Successful in 1m23s
657e1c3bde
Post-merge Lighthouse re-verification of PR #47 confirmed article TBT
regression is resolved (7416ms -> 0-348ms, Performance 60 -> 99 median,
5 runs, results in PERFORMANCE_BASELINE.md). This follow-up closes a
gap found during that verification and widens the pass margin:

- bridge/package.json: sanitize-html.test.ts (added in the original
  fix) was never wired into the test/test:coverage scripts, so the
  "28 bridge sanitizer tests pass" claim wasn't actually exercised by
  npm test. Fixed.
- Defer mobile-menu and share-button click handlers to
  requestIdleCallback (institutional/sports headers, ArticleShareBar)
  so they don't compete with hydration-critical work.
- Split Base.astro's theme-flash-prevention script into a minimal
  inline snippet (runs before paint) and the deferred click-handler
  logic, instead of one blocking script.
- bridge articles route: /articles/:slug/related accepts an optional
  ?category_id= to skip a redundant WP post-by-slug fetch when the
  caller already has it.

Paperclip-Agent: Miguel Teixeira (urlKey miguel-teixeira; id 0f722e1a-bc3e-4381-8d98-76fa3c7aea10)
Paperclip-Issue: BIT-28145
paperclip-review-bot left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
founding-engineer left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
devops-engineer left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
spark scheduled this pull request to auto merge when all checks succeed 2026-08-07 10:33:24 +01:00
spark merged commit 71e7697c29 into main 2026-08-07 10:33:26 +01:00
Sign in to join this conversation.