From c7f79a4b96e284bc71e08481f12bc9038a69191c Mon Sep 17 00:00:00 2001 From: cesnimda Date: Fri, 20 Nov 2026 13:56:29 +0100 Subject: [PATCH] Reserve landing preview geometry and defer secondary images --- .../landing-previews/QUALIFICATION.md | 28 ++++++ .../landing-previews/after.json.gz | Bin 0 -> 1077 bytes .../landing-previews/before.json.gz | Bin 0 -> 1133 bytes docs/performance/landing-previews/measure.mjs | 95 ++++++++++++++++++ job-tracker-ui/src/landing-page.test.tsx | 16 +++ job-tracker-ui/src/views/LandingPage.tsx | 8 +- 6 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 docs/performance/landing-previews/QUALIFICATION.md create mode 100644 docs/performance/landing-previews/after.json.gz create mode 100644 docs/performance/landing-previews/before.json.gz create mode 100644 docs/performance/landing-previews/measure.mjs diff --git a/docs/performance/landing-previews/QUALIFICATION.md b/docs/performance/landing-previews/QUALIFICATION.md new file mode 100644 index 00000000..4602b1d0 --- /dev/null +++ b/docs/performance/landing-previews/QUALIFICATION.md @@ -0,0 +1,28 @@ +# Public landing preview measurements + +The landing page now reserves the space occupied by its three 1440 × 900 SVG previews while the files are in flight. The dashboard preview begins within the first viewport on desktop and tablet and keeps its default eager load. The two subsequent previews use the browser’s native lazy loading. All three retain their original files, order and translated alternative text. + +## Local browser results + +Each row covers two cold Chromium 151.0.7922.34 contexts, English/light and Norwegian Bokmål/dark. The probe served the real static exports on loopback with synthetic signed-out authentication responses. It held the SVG response bodies until it could measure their pending layout. The displacement column measures the change in the last preview’s bottom edge in CSS pixels between pending and decoded states. The request and byte columns cover the three previews and the favicon only. The server served these assets uncompressed. + +| Viewport | Preview displacement before → after | Initial asset requests before → after | Initial body bytes before → after | +| --- | ---: | ---: | ---: | +| 1440 × 900 | 1,132 → 0 | 4 → 4 | 28,397 → 28,397 | +| 768 × 1024 | 1,346 → 0 | 4 → 4 | 28,397 → 28,397 | +| 390 × 844 | 668 → 0 | 4 → 4 | 28,397 → 28,397 | +| 320 × 568 | 537 → 0 | 4 → 4 | 28,397 → 28,397 | +| 844 × 390 | 1,488 → 0 | 4 → 3 | 28,397 → 18,036 | + +All ten comparisons retained the exact settled top, width, height and alternative text of each image. Chromium loaded the 10,361-byte workspace preview on scroll in both landscape-phone samples. Scrolling through the page decoded every image once per sample. In the other eight samples Chromium prefetched the secondary images before scrolling. + +Every cold context requested the 1,017-byte SVG favicon. Requests for the ICO, manifest and PWA PNGs totaled zero in this navigation sample. Those assets remain available for other browser and install flows. Browser prefetch distances can vary. Production latency, field Core Web Vitals, other browser engines, physical devices and the future launch design remain open. + +## Reproduction and verification + +From an installed `job-tracker-ui` checkout, run `node ../docs/performance/landing-previews/measure.mjs ` for each build. The JSON output includes pending and settled image rectangles, local request paths, response-body sizes and the browser version. The probe checks the document language, successful image decoding, accessible labels and absence of unexpected application requests or errors. The paired receipts are [before](before.json.gz) and [after](after.json.gz). + +- Application source baseline `245f2feaa8bee2db8f5da0797b3e33f6ef8b056e`. The baseline export resided at checkout `171e616b`. Git reported an empty `job-tracker-ui` diff between those commits. Baseline index SHA-256 `31dfd9b2d2e7ea7d9e696b5485d24d7b8daf0b1e078e6539e94a04955b8ff1f8`. +- Candidate landing component blob `a73053174690588c5764f09683d5cabb0fe270e8`. Candidate index SHA-256 `8a8c1121f8a54fad47b91348346ca483bc0e4c06bd1211c85de525931a9d46d8`. Both checkouts used lockfile SHA-256 `1f718d8faa55f5e540d3d7886a51dd19b02b916b6cb23a462ae229e388d7ab98`. +- The new regression check caught missing native width and height attributes on the first implementation with MUI Box. The final native images passed. Three suites passed 41 tests covering landing content, language, auth redirect and public auth presentation. Scoped ESLint passed. The ordinary Next 16.4.6 production build passed TypeScript checking and static export. +- PERF-04 and PERF-15 remain partial. Launch image selection and rights, install-specific devices, other app routes and deployed delivery require their own evidence. A revert of this application change restores the previous eager previews and loading geometry. diff --git a/docs/performance/landing-previews/after.json.gz b/docs/performance/landing-previews/after.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..18f352f6dbe24f82058979f1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xEZ4Nd?6Rq`D{ literal 0 HcmV?d00001 diff --git a/docs/performance/landing-previews/before.json.gz b/docs/performance/landing-previews/before.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..4db614a0a46faba689bc54429237850e5a50487c GIT binary patch literal 1133 zcmV-z1d{t7iwFP!000023hkRsZreB<#rHi0p|zZd`lfdS%wpPZy6d9og0g5?wJZuG zW1}bv^boy5@6dg2(vy^O62+5|N;xA-w8KRb*!tiz`SgGOk<1q>VRXj{v*s2I;FWU~ zA=ka~e9N}Dz=CjV{^5(Y%Tuwk=Fs;Y+gg!4TM2899QmTaWhSpBrMy6_$cD%l#s0W$ zRisSw`mnqMXA61cdP5iMn~Gnjn6DCwS$f5{S$!$3ta%(DyJ^aW;bT*>AzaA6)*G56 zpYU3M<_6%`x9{NXyVu+X%bT(!g$)?t6)iadf=LAc%bz7J3c8!gre$L#7B>tR@9$c2 znm7J=Xzi>0AHh{#ks>e2zx2jIqc=c7i`>5%&StXxS;}Yy9_|75!k;N*N7VTv!8Zjqs0qh zt)3Gh3X-0s`uYlGfS1WZfTx(PPn+K}x+RR~@-g0!6qL6=*K1M;T*zlvFnQbte2dxL z(@Qfzt7>`sv&f_xSx-hz@EOf!yvVC+Ch)c(vXU^srQ#B&yke9S&i7w`Moja+SVHoY z(+#`*krGf52IQlh>^qa=P2G1kST_$Zu1lfp#w|$;l4Uw1`Je_EsenJv2%{A9fekTH zrW;e7t113>x*r#KN2ck?(|tnq2k9P#@uLr*?;3R&X}wH}T&3)B zam+*Nj?^2>jT0``2?oq{0Q0W+9s0b7 z{niS^TrciZ!6yPS-&c35ws3At@ghuN=v)Ij-%qtS|J8t;6K-Zl{#k8iZ4L#6C-i7fJCrK0oM%x;`;QBE*yt^u2OhWFrm+5ec`I__ofO7Cg+ zvbU { + try { + const pathname = new URL(req.url, 'http://localhost').pathname; + const file = path.resolve(root, '.' + (pathname === '/' ? '/index.html' : pathname)); + if (req.method !== 'GET' || !file.startsWith(root + path.sep)) { + res.writeHead(400).end(); + return; + } + const body = await readFile(file); + if (tracked.has(pathname)) requests.push({ path: pathname, bytes: body.length }); + if (previews.includes(pathname)) await imageGate; + res.writeHead(200, { 'Content-Type': mime[path.extname(file)] || 'application/octet-stream', 'Cache-Control': 'no-store' }); + res.end(body); + } catch { + res.writeHead(404).end(); + } +}); + +await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); +const origin = 'http://127.0.0.1:' + server.address().port; +const browser = await chromium.launch({ channel: 'chromium', args: ['--disable-background-networking'] }); +try { + const states = []; + for (const [width, height] of [[1440, 900], [768, 1024], [390, 844], [320, 568], [844, 390]]) { + for (const [lang, theme] of [['en', 'light'], ['nb', 'dark']]) { + const begin = requests.length; + let release; + imageGate = new Promise(resolve => { release = resolve; }); + const context = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: 1, colorScheme: theme, serviceWorkers: 'block' }); + const page = await context.newPage(); + const unexpected = []; + page.on('pageerror', error => unexpected.push(error.message)); + await page.addInitScript(({ lang, theme }) => { + localStorage.setItem('uiLanguage', lang); + localStorage.setItem('jobtracker.themeMode', theme); + }, { lang, theme }); + await context.route('**/*', route => { + const url = new URL(route.request().url()); + const local = ['127.0.0.1', 'localhost'].includes(url.hostname); + if (local && route.request().method() === 'GET' && url.pathname === '/api/auth/me') return route.fulfill({ status: 401, json: {} }); + if (local && route.request().method() === 'GET' && url.pathname === '/api/auth/config') { + return route.fulfill({ json: { requireAuth: true, localEnabled: true, allowRegistration: true } }); + } + if (origin === url.origin && !url.pathname.startsWith('/api/')) return route.continue(); + unexpected.push(url.pathname); + return route.abort(); + }); + + const images = page.locator('main img[src^="/mockups/"]'); + const boxes = () => images.evaluateAll(nodes => nodes.map(image => { + const rect = image.getBoundingClientRect(); + return { src: image.getAttribute('src'), top: Math.round(rect.top + scrollY), width: Math.round(rect.width), height: Math.round(rect.height), alt: image.alt, naturalWidth: image.naturalWidth, naturalHeight: image.naturalHeight }; + })); + await page.goto(origin, { waitUntil: 'domcontentloaded' }); + await page.getByRole('heading', { level: 1 }).waitFor(); + await images.nth(2).waitFor({ state: 'attached' }); + await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))); + const pending = await boxes(); + release(); + await page.waitForLoadState('networkidle'); + const before = await boxes(); + const initial = requests.slice(begin); + assert.equal(await page.locator('html').getAttribute('lang'), lang === 'nb' ? 'nb-NO' : 'en'); + for (const image of await images.all()) { + await image.scrollIntoViewIfNeeded(); + await image.evaluate(element => element.decode()); + } + const after = await boxes(); + assert.deepEqual(after.map(image => image.src), previews); + assert.ok(after.every(image => image.alt && image.naturalWidth === 1440 && image.naturalHeight === 900)); + assert.deepEqual(unexpected, []); + states.push({ width, height, lang, theme, pending, before, after, initial, settled: requests.slice(begin) }); + await context.close(); + } + } + console.log(JSON.stringify({ browser: browser.version(), states }, null, 2)); +} finally { + await browser.close(); + server.closeAllConnections(); + await new Promise(resolve => server.close(resolve)); +} diff --git a/job-tracker-ui/src/landing-page.test.tsx b/job-tracker-ui/src/landing-page.test.tsx index 63841c03..52557add 100644 --- a/job-tracker-ui/src/landing-page.test.tsx +++ b/job-tracker-ui/src/landing-page.test.tsx @@ -50,6 +50,22 @@ test("shows exactly Free and Pro without invented commercial terms", async () => expect(mockNavigate).toHaveBeenCalledWith("/login", { state: { from: "/settings" } }); }); +test("reserves preview dimensions and keeps the first preview eager", async () => { + render(); + const previews = await screen.findAllByRole("img"); + expect(previews.map(image => image.getAttribute("src"))).toEqual([ + "/mockups/dashboard.svg", "/mockups/pipeline.svg", "/mockups/workspace.svg", + ]); + for (const image of previews) { + expect(image).toHaveAttribute("width", "1440"); + expect(image).toHaveAttribute("height", "900"); + expect(image).toHaveAccessibleName(); + } + expect(previews[0]).not.toHaveAttribute("loading", "lazy"); + expect(previews[1]).toHaveAttribute("loading", "lazy"); + expect(previews[2]).toHaveAttribute("loading", "lazy"); +}); + test.each([ ["en", "Norsk bokmål", "nb", "nb-NO", "To tydelige alternativer"], ["nb", "English", "en", "en", "Two clear plans"], diff --git a/job-tracker-ui/src/views/LandingPage.tsx b/job-tracker-ui/src/views/LandingPage.tsx index deaeb7dc..a7305317 100644 --- a/job-tracker-ui/src/views/LandingPage.tsx +++ b/job-tracker-ui/src/views/LandingPage.tsx @@ -138,20 +138,20 @@ export default function LandingPage() { {/* Product preview */} - + {t("landingPreviewEyebrow")} {t("landingPreviewTitle")} - + {t("landingDashboardAlt")} - + {t("landingPipelineAlt")} - + {t("landingWorkspaceAlt")} {t("landingPreviewCaption")}