A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
perf(web): paint prerendered pages before loading the app
Amruth Pillai702e33d5f5e2
diff --git a/apps/web/DESIGN.md b/apps/web/DESIGN.mdindex 7245db84a..22197bef6 100644--- a/apps/web/DESIGN.md+++ b/apps/web/DESIGN.md@@ -274,14 +274,14 @@ Reduced motion fixes scenes at their end state and collapses pinned sections to### Illustration-- Ten watercolour doodles live in `apps/web/public/doodles/` as transparent WebP (up to 800px, plus a 400px `-small`): pencil, paperclip, eraser, curve, magnifier, scissors, plane, globe, jar, and note. They share the footer desk's style: soft washes, thin blue-grey pen lines, cream, sage, moss, slate blue, terracotta and ochre. Prompts and references for regenerating them are kept outside the repo; each is trimmed to its content and its faint background alpha cleaned (`-channel A -level 4%,100%`) before encoding losslessly in alpha (`cwebp -q 82 -alpha_q 100 -exact`), and its size goes in `doodleSizes` (`ui.tsx`). The magnifier is not trimmed: its empty glass is the Check lens, so `check.tsx` positions it from the lens's measured centre and radius in the 1024px source.+- Ten watercolour doodles live in `apps/web/public/doodles/` as transparent WebP (up to 800px, plus a half-size `-small` and a quarter-size `-tiny`, each resized from the full file with `magick -filter Lanczos` and encoded with the same `cwebp` settings): pencil, paperclip, eraser, curve, magnifier, scissors, plane, globe, jar, and note. They share the footer desk's style: soft washes, thin blue-grey pen lines, cream, sage, moss, slate blue, terracotta and ochre. Prompts and references for regenerating them are kept outside the repo; each is trimmed to its content and its faint background alpha cleaned (`-channel A -level 4%,100%`) before encoding losslessly in alpha (`cwebp -q 82 -alpha_q 100 -exact`), and its size goes in `doodleSizes` (`ui.tsx`). The magnifier is not trimmed: its empty glass is the Check lens, so `check.tsx` positions it from the lens's measured centre and radius in the 1024px source.- Doodles appear through a 110° mask wipe with subtle parallax. They keep their colours in both themes: opacity 0.92 in light mode, 0.8 and slightly dimmed (`brightness(0.92)`) in dark. No drop shadows: a hard shadow draws the image's box against the paper texture. The Share plane fades in with the night sky.- Most doodles hide below 900px; pencil and plane remain. Keep them decorative, noninteractive, and clear of readable text.- Construction guides use `graphite` lines with an SVG turbulence filter for a pencil effect.### Content and delivery-- Prerender the homepage and public ATS checker per locale at build time through `prerender.tsx` and `apps/web/vite.config.ts`. The app is a client-rendered SPA; `apps/server/src/static/web.ts` serves the generated HTML and adds canonical, Open Graph, `hreflang`, and structured data. Keep headings and body copy in the initial HTML.+- Prerender the homepage and public ATS checker per locale at build time through `prerender.tsx` and `apps/web/vite.config.ts`. The app is a client-rendered SPA; `apps/server/src/static/web.ts` serves the generated HTML and adds canonical, Open Graph, `hreflang`, and structured data. Keep headings and body copy in the initial HTML. Prerendered pages start the app's JavaScript only after the first contentful paint (the loader in `vite.config.ts`), so their first screen must not depend on it, and must not fade in on load: the largest paint would wait for the fade.- Include title and description metadata and `SoftwareApplication` structured data with a zero-price offer.- **Template previews** come from each template's sample PDF (`apps/web/public/templates/pdf/<id>.pdf`), never at print resolution: `templates/jpg/<id>.jpg` at 600×848 (builder and letter cards, the mobile picker and the README; old mobile builds load this URL, so it stays a JPEG), and `templates/thumb/<id>.webp` at 596×843 with a 300×424 `<id>-small.webp` (homepage and gallery). Regenerate them with the server's sharp:diff --git a/apps/web/public/doodles/curve-tiny.webp b/apps/web/public/doodles/curve-tiny.webpnew file mode 100644index 000000000..d3b830b93Binary files /dev/null and b/apps/web/public/doodles/curve-tiny.webp differdiff --git a/apps/web/public/doodles/eraser-tiny.webp b/apps/web/public/doodles/eraser-tiny.webpnew file mode 100644index 000000000..d39e7ba6bBinary files /dev/null and b/apps/web/public/doodles/eraser-tiny.webp differdiff --git a/apps/web/public/doodles/globe-tiny.webp b/apps/web/public/doodles/globe-tiny.webpnew file mode 100644index 000000000..3f87d291eBinary files /dev/null and b/apps/web/public/doodles/globe-tiny.webp differdiff --git a/apps/web/public/doodles/jar-tiny.webp b/apps/web/public/doodles/jar-tiny.webpnew file mode 100644index 000000000..23153038aBinary files /dev/null and b/apps/web/public/doodles/jar-tiny.webp differdiff --git a/apps/web/public/doodles/magnifier-tiny.webp b/apps/web/public/doodles/magnifier-tiny.webpnew file mode 100644index 000000000..f232e64b1Binary files /dev/null and b/apps/web/public/doodles/magnifier-tiny.webp differdiff --git a/apps/web/public/doodles/note-tiny.webp b/apps/web/public/doodles/note-tiny.webpnew file mode 100644index 000000000..c644bdaefBinary files /dev/null and b/apps/web/public/doodles/note-tiny.webp differdiff --git a/apps/web/public/doodles/paperclip-tiny.webp b/apps/web/public/doodles/paperclip-tiny.webpnew file mode 100644index 000000000..30450dcffBinary files /dev/null and b/apps/web/public/doodles/paperclip-tiny.webp differdiff --git a/apps/web/public/doodles/pencil-tiny.webp b/apps/web/public/doodles/pencil-tiny.webpnew file mode 100644index 000000000..41ca14196Binary files /dev/null and b/apps/web/public/doodles/pencil-tiny.webp differdiff --git a/apps/web/public/doodles/plane-tiny.webp b/apps/web/public/doodles/plane-tiny.webpnew file mode 100644index 000000000..ac95492caBinary files /dev/null and b/apps/web/public/doodles/plane-tiny.webp differdiff --git a/apps/web/public/doodles/scissors-tiny.webp b/apps/web/public/doodles/scissors-tiny.webpnew file mode 100644index 000000000..d3c09439eBinary files /dev/null and b/apps/web/public/doodles/scissors-tiny.webp differdiff --git a/apps/web/src/features/ats-checker/checker.tsx b/apps/web/src/features/ats-checker/checker.tsxindex 23f4608bc..fb891385f 100644--- a/apps/web/src/features/ats-checker/checker.tsx+++ b/apps/web/src/features/ats-checker/checker.tsx@@ -6,6 +6,7 @@ import { t } from "@lingui/core/macro";import { Plural, Trans } from "@lingui/react/macro";import { useNavigate } from "@tanstack/react-router";import { lazy, Suspense, useEffect, useId, useRef, useState } from "react";+import { useIsClient } from "usehooks-ts";import { Button } from "@reactive-resume/ui/components/button";import { Collapsible, CollapsibleContent } from "@reactive-resume/ui/components/collapsible";import { Icon } from "@reactive-resume/ui/components/icon";@@ -118,11 +119,17 @@ export function AtsChecker({ signedIn, importPending }: AtsCheckerProps) {});useEffect(() => () => abort.current?.abort(), []);+ // The first state is already on screen (the page is prerendered), so only the states that replace it fade in;+ // fading it too would hold back the page's largest paint until the app had loaded.+ const replacing = useIsClient();// Each state fades in as it replaces the last. Opacity only: a translate here would make this wrapper the// containing block for the result's fixed mobile bar while it animates.return (- <div key={state.name} className="transition-opacity duration-standard ease-enter starting:opacity-0">+ <div+ key={state.name}+ className={cn(replacing && "transition-opacity duration-standard ease-enter starting:opacity-0")}+ >{state.name === "importing" ? (<p role="status" className="flex items-center justify-center gap-2 py-24 text-ink-2"><Spinner decorative className="size-4" />diff --git a/apps/web/src/features/homepage/check.tsx b/apps/web/src/features/homepage/check.tsxindex 88c2df734..724e44a01 100644--- a/apps/web/src/features/homepage/check.tsx+++ b/apps/web/src/features/homepage/check.tsx@@ -227,6 +227,7 @@ export function Check() {<Doodlename="magnifier"wipe="1"+ sizes="(min-width: 900px) 14vw, 31vw"className="top-[calc(var(--ly,16%)-15.9cqw)] left-[calc(var(--lx,50%)-17.4cqw)] w-[48.3cqw] max-w-none [mask-image:radial-gradient(circle_11cqw_at_36.1%_32.9%,transparent_97%,#000_100%)]! [mask-size:100%_100%]! [mask-position:0_0]! opacity-(--lo)!"/><spandiff --git a/apps/web/src/features/homepage/design.tsx b/apps/web/src/features/homepage/design.tsxindex d9adda62f..525a3016d 100644--- a/apps/web/src/features/homepage/design.tsx+++ b/apps/web/src/features/homepage/design.tsx@@ -73,6 +73,7 @@ export function Design() {<Doodlename="curve"wipe="clamp(0, (var(--p) - .03) / .2, 1)"+ sizes="16vw"className="start-[79vw] top-[62vh] w-[16vw] translate-y-[calc(var(--p)*-50px)] rotate-[8deg] [--doodle-fade:calc(1-var(--z))] max-[900px]:hidden"/>diff --git a/apps/web/src/features/homepage/hero.tsx b/apps/web/src/features/homepage/hero.tsxindex 16d79caf9..8e826d26e 100644--- a/apps/web/src/features/homepage/hero.tsx+++ b/apps/web/src/features/homepage/hero.tsx@@ -199,12 +199,14 @@ export function Hero() {name="pencil"eagerwipe="var(--ld, 0)"+ sizes="12vw"className="start-[74vw] top-[max(15vh,110px)] w-[12vw] [transform:translate(calc(var(--mx,0)*-22px),calc(var(--my,0)*-14px))_rotate(calc(-22deg+var(--mx,0)*3deg))_translateY(calc(var(--p)*-20px))] [transition:mask-position_1.8s_var(--ease)_.9s,transform_.9s_var(--ease)]"/><Doodlename="paperclip"eagerwipe="var(--ld, 0)"+ sizes="(min-width: 900px) 6vw, 1px"className="start-[4vw] top-[61%] w-[6vw] [transform:translate(calc(var(--mx,0)*22px),calc(var(--my,0)*16px))_rotate(calc(16deg+var(--mx,0)*-4deg))_translateY(calc(var(--p)*-30px))] [transition:mask-position_1.4s_var(--ease)_1.3s,transform_1.1s_var(--ease)] max-[900px]:hidden"/>diff --git a/apps/web/src/features/homepage/prepare.tsx b/apps/web/src/features/homepage/prepare.tsxindex 632ddae87..c5d80f8fa 100644--- a/apps/web/src/features/homepage/prepare.tsx+++ b/apps/web/src/features/homepage/prepare.tsx@@ -705,6 +705,7 @@ export function Prepare() {<Doodlename="plane"wipe="1"+ sizes="9vw"className="end-[21vw] top-[6vh] z-4 w-[9vw] [transform:translate(calc(var(--dir)*(1-var(--pl))*30vw),calc((1-var(--pl))*-30vh))_scaleX(calc(var(--dir)*-1))_rotate(calc(-18deg+var(--pl)*14deg))] opacity-[calc(.8*(1-clamp(0,(var(--p)-.12)*12,1)))]! [transition:transform_.4s_var(--ease)] max-[900px]:hidden"/>diff --git a/apps/web/src/features/homepage/remember.tsx b/apps/web/src/features/homepage/remember.tsxindex 511a06f69..7301eaef8 100644--- a/apps/web/src/features/homepage/remember.tsx+++ b/apps/web/src/features/homepage/remember.tsx@@ -199,6 +199,7 @@ export function Remember() {<Doodlename="paperclip"wipe="clamp(0, (var(--p) - .3) / .2, 1)"+ sizes="64px"className="end-[10%] -top-[46px] z-2 w-[64px] rotate-[78deg]"/><divdiff --git a/apps/web/src/features/homepage/sections.tsx b/apps/web/src/features/homepage/sections.tsxindex 5900f885b..bf65c4ba3 100644--- a/apps/web/src/features/homepage/sections.tsx+++ b/apps/web/src/features/homepage/sections.tsx@@ -124,6 +124,7 @@ export function Languages() {<Doodlename="globe"wipe="clamp(0, (var(--p) - .25) / .2, 1)"+ sizes="11vw"className="start-[6vw] top-[10vh] w-[11vw] translate-y-[calc(var(--p)*-40px)] rotate-[-6deg] max-[900px]:hidden"/><h2 id="languages-title" className={cn(labelClass, "text-ink-3")}>@@ -220,6 +221,7 @@ export function Support() {<Doodlename="jar"wipe="clamp(0, (var(--p) - .3) / .2, 1)"+ sizes="9vw"className="start-[3vw] bottom-[4vh] w-[9vw] translate-y-[calc(var(--p)*-30px)] rotate-[4deg] max-[900px]:hidden"/>diff --git a/apps/web/src/features/homepage/share.tsx b/apps/web/src/features/homepage/share.tsxindex db213bb17..2d53d5db4 100644--- a/apps/web/src/features/homepage/share.tsx+++ b/apps/web/src/features/homepage/share.tsx@@ -108,6 +108,7 @@ export function Share() {<Doodlename="plane"wipe="clamp(0, (var(--p) - .12) / .2, 1)"+ sizes="14vw"className="start-[7vw] top-[max(13vh,120px)] w-[14vw] translate-y-[calc(var(--p)*-30px)] rotate-[-8deg] opacity-[calc(var(--nt)*.85)]!"/>diff --git a/apps/web/src/features/homepage/tailor.tsx b/apps/web/src/features/homepage/tailor.tsxindex 862fd6e98..9ac273ee0 100644--- a/apps/web/src/features/homepage/tailor.tsx+++ b/apps/web/src/features/homepage/tailor.tsx@@ -50,6 +50,7 @@ export function Tailor() {<Doodlename="scissors"wipe="clamp(0, (var(--p) - .08) / .2, 1)"+ sizes="12vw"className="start-[41vw] top-[74vh] w-[12vw] translate-y-[calc(var(--p)*-40px)] rotate-[12deg] max-[900px]:hidden"/>diff --git a/apps/web/src/features/homepage/ui.tsx b/apps/web/src/features/homepage/ui.tsxindex 9c89cfb44..2de4a4814 100644--- a/apps/web/src/features/homepage/ui.tsx+++ b/apps/web/src/features/homepage/ui.tsx@@ -73,23 +73,32 @@ type DoodleProps = {className?: string;style?: CSSProperties;eager?: boolean;+ /** The width it's drawn at, for picking a file (`img` sizes). Below 900px most doodles hide; a hidden eager one says 1px. */+ sizes?: string;};/** A watercolour doodle. Decorative, so it's hidden from assistive tech and never takes the pointer. */-export function Doodle({ name, wipe, className, style, eager = false }: DoodleProps) {+export function Doodle({+ name,+ wipe,+ className,+ style,+ eager = false,+ sizes = "(min-width: 900px) 10vw, 30vw",+}: DoodleProps) {const [width, height] = doodleSizes[name];return (<imgsrc={`/doodles/${name}.webp`}- srcSet={`/doodles/${name}-small.webp ${Math.round(width / 2)}w, /doodles/${name}.webp ${width}w`}- // ponytail: one size for every doodle (they render at 6–16vw); curve and globe upscale the small file up to 1.15×- // on 2× screens. Add a per-use `sizes` prop if that ever shows.- sizes="(min-width: 900px) 10vw, 30vw"+ srcSet={`/doodles/${name}-tiny.webp ${Math.round(width / 4)}w, /doodles/${name}-small.webp ${Math.round(width / 2)}w, /doodles/${name}.webp ${width}w`}+ sizes={sizes}alt=""aria-hidden="true"width={width}height={height}loading={eager ? "eager" : "lazy"}+ // Eager doodles sit on the first screen; the pencil is the largest paint on desktop.+ fetchPriority={eager ? "high" : "auto"}decoding="async"draggable={false}className={cn("doodle", className)}diff --git a/apps/web/src/features/homepage/write.tsx b/apps/web/src/features/homepage/write.tsxindex 6a7bc6053..e1cfb7799 100644--- a/apps/web/src/features/homepage/write.tsx+++ b/apps/web/src/features/homepage/write.tsx@@ -62,6 +62,7 @@ export function Write() {<Doodlename="eraser"wipe="clamp(0, (var(--p) - .02) / .2, 1)"+ sizes="10vw"className="start-[7vw] top-[36vh] w-[10vw] translate-y-[calc(var(--p)*-50px)] rotate-[-10deg] max-[900px]:hidden"/>diff --git a/apps/web/src/features/templates/gallery.tsx b/apps/web/src/features/templates/gallery.tsxindex da9500ac6..e63fbcecf 100644--- a/apps/web/src/features/templates/gallery.tsx+++ b/apps/web/src/features/templates/gallery.tsx@@ -36,7 +36,7 @@ export function TemplateGallery() {</div><div className="grid gap-x-8 gap-y-12 sm:grid-cols-2 lg:grid-cols-3">- {templateSchema.options.map((id) => {+ {templateSchema.options.map((id, index) => {const template = templates[id];const name = template.name;const layout = templateLayouts[id];@@ -54,7 +54,9 @@ export function TemplateGallery() {alt={t`${name} resume template preview`}width={298}height={420}- loading="lazy"+ // The first row is on the first screen, and the first preview is its largest paint.+ loading={index < 3 ? "eager" : "lazy"}+ fetchPriority={index === 0 ? "high" : "auto"}decoding="async"className="mx-auto aspect-[298/420] w-full max-w-74.5 bg-white object-contain shadow-e2"/>diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.tsindex 168278266..0d3a6dd50 100644--- a/apps/web/vite.config.ts+++ b/apps/web/vite.config.ts@@ -45,6 +45,35 @@ async function prerenderPages() {}).join("");+ // The page is readable before any script runs, so the app's JavaScript starts after the first contentful paint: the+ // stylesheet, fonts and images get the bandwidth first, and lab tools stop counting the scripts toward that paint.+ // The module preloads move into the same moment, so the entry's imports still download in parallel.+ const entry = /<script type="module"[^>]*\ssrc="([^"]+)"[^>]*><\/script>\s*/.exec(shell);+ if (!entry?.[1]) throw new Error("Missing the app's entry script in index.html");+ const modulePreloads = [...shell.matchAll(/<link rel="modulepreload"[^>]*\shref="([^"]+)"[^>]*>\s*/g)];+ const loadApp = `<script data-cfasync="false">(() => {+ let started = false;+ const start = () => {+ if (started) return;+ started = true;+ for (const href of ${JSON.stringify(modulePreloads.map(([, href]) => href))})+ document.head.append(Object.assign(document.createElement("link"), { rel: "modulepreload", href, crossOrigin: "" }));+ import(${JSON.stringify(entry[1])});+ };+ try {+ new PerformanceObserver((list) => {+ if (list.getEntriesByName("first-contentful-paint").length) setTimeout(start);+ }).observe({ type: "paint", buffered: true });+ } catch {+ start();+ }+ // A browser that reports no paint, or a tab opened in the background, starts anyway.+ setTimeout(start, 3000);+})();</script>`;+ const pageShell = modulePreloads+ .reduce((html, [tag]) => html.replace(tag, ""), shell.replace(entry[0], ""))+ .replace("</body>", () => `${loadApp}</body>`);+await rm(prerenderOutDir, { recursive: true, force: true });for (const name of prerenderedPages) {@@ -52,7 +81,7 @@ async function prerenderPages() {for (const locale of locales) {const page = await renderPage(name, locale);- const html = shell+ const html = pageShell.replace("</head>", `${fontPreloads}</head>`).replace(/<html lang="[^"]*">/, () => `<html lang="${locale}" dir="${page.dir}">`).replace(/<title>[^<]*<\/title>/, () => `<title>${escapeHtml(page.title)}</title>`)@@ -60,10 +89,7 @@ async function prerenderPages() {/<meta\s+name="description"[^>]*>/,() => `<meta name="description" content="${escapeHtml(page.description)}">`,)- .replace('<div id="app"></div>', () => `<div id="app">${page.html}</div>`)- // The page is readable before any script runs, so the stylesheet, fonts and images go first.- .replaceAll('<link rel="modulepreload" ', '<link rel="modulepreload" fetchpriority="low" ')- .replace('<script type="module" ', '<script type="module" fetchpriority="low" ');+ .replace('<div id="app"></div>', () => `<div id="app">${page.html}</div>`);await writeFile(`${prerenderOutDir}/${name}/${locale}.html`, html);}}