Hybrid Frontend — full notes, searchable
Source: rapid frontend.md (435 lines) plus the appended 99-line agent box. Nothing from the source was deleted. Search the page. Toggle paper / ink. Open a box, copy, run. Need everything in one paste? Use the large UNIFIED box.
LARGE UNIFIED HYBRID — all small boxes in one paste
Contains every small box below (how-to, 99-line agent, rules, golden, stack, never-do, tips, prompts, checklist, fluid CSS, no-React-state). One click copies the full hybrid for an AI agent.
How to use these notes
- Live build of a content site → paste the 99-line box into the agent first.
- Pick a stack from §4 before writing code. Do not default to React for docs.
- Then open the matching prompt in §7 (scaffold / virtualize / Pagefind / audit).
- This organizer itself follows the below-part: CSS
:checked-free details, clamp,dvh, no React state.
99-line AI-agent paste box
Title: Hybrid Frontend Architecture Agent — Static-First SSG, Islands Hydration, Virtualized Lists, Prefetch, Event Delegation, Pagefind, CDN
Function role
- Operating manual for huge-content sites that must stay fast, stable, and low-RAM: SSG many small pages, not one giant HTML.
- Eight hybrid rules plus five golden rules: one topic/page, zero-JS default, virtualize/paginate, lazy, prefetch, one parent listener, content in MD/JSON, Brotli+CDN.
- Stack picker (Astro/Pagefind vs SvelteKit+TanStack vs plain HTML vs SSR+Meilisearch) and a never-do list.
- Copy-paste AI prompts for scaffold, virtual list, Pagefind, audit, monolith migration, hover-prefetch, delegation.
- Below-the-box organizer: search, two themes, expandable sections, fluid clamp/dvh CSS, CSS-first UI with almost no React state.
1 · Executive summary
All three source voices agree: the file structure matters less than the rendering and delivery strategy. A single giant HTML file will choke the browser. Splitting folders is not enough.
Use a static-first, demand-driven, minimally-hydrated architecture. Only render, load, and execute what the user needs now.
SSG → many small HTML pages → minimal JS → lazy load → CDN + Brotli + cache → virtualize long lists.
HTML + CSS + JavaScript. Not Java. A standalone file can hold huge text, but the DOM tree will lag. The holy grail is huge content + lightning clicks + low RAM.
2 · Eight hybrid rules
- One topic = one page. Build-time HTML per article. Small DOM, granular cache, instant nav.
- Zero-JS default, hydrate by exception. Islands. JS only for search, filters, virtual scroll.
- Virtualize or paginate. 20–100 items to browse. Visible rows only for long scroll. Never 10k–100k nodes.
- Load on demand.
loading="lazy"+ IntersectionObserver. Search index only when search opens. API fetch on scroll/click. - Prefetch the next step.
<link rel="prefetch">on hover. MPA feels like SPA. - One parent listener. Event delegation. Memory stays flat.
- Content in Markdown/JSON/CMS. Thin shell. Never hardcode mass content into bundles.
- Brotli/gzip + cache + CDN. Cloudflare / Vercel / Netlify. Service worker only if offline is required.
3 · Five golden rules
- DOM: never more than 50–100 items at once. Window ~20 visible rows. 60fps, flat RAM.
- Delivery: Astro or Hugo static HTML. Alpine.js ~15KB or htmx ~14KB. No React/Angular on content pages.
- Anticipation: hover prefetch + immutable cache on hashed assets.
- On-demand: lazy images, code-split JS per topic, paginate long lists.
- Events: parent listener +
closest("[data-id]").
Hard limits from the source: ≤1,500 DOM nodes/page · ≤200KB JS/page · ≤3s TTI · prefer ≤50KB JS. Test 6× CPU throttle.
4 · Decision matrix — which stack
| Situation | Stack | Why |
|---|---|---|
| Docs, wiki, blog, KB | Astro + Markdown + Pagefind + CDN | Zero-JS default, SEO, fastest loads |
| Dashboards, logs, huge tables | SvelteKit / SolidStart + TanStack Virtual + API | Light reactivity, virtualization |
| No-build, ultra simple | Plain HTML + vanilla JS + pagination | Zero deps, trivial host |
| User-generated, dynamic | Next.js / Nuxt SSR + Meilisearch + CDN | Freshness + search |
| SPA feel without SPA weight | Astro + htmx/Alpine + prefetch | Still multi-page under the hood |
SSG: Astro zero JS · 11ty simple · Hugo fastest Go. Content stays in MD/JSON.
5 · Never-do list
| Do not | Do instead |
|---|---|
| One HTML with 50,000 lines | Split pages; SSG |
| All topics on the homepage | Paginate or topic index |
| 100,000 table rows in the DOM | Virtualize or server paginate |
| Ship React for a static blog | Astro or plain HTML |
| Click listener on every item | One parent listener |
| Search index on every load | Lazy load when search opens |
| Ignore cache headers | Immutable assets, revalidate HTML |
6 · Actionable tips
Content
- Markdown/MDX — portable, versioned, writing ≠ code.
- Folders
/content/category/topic.mdauto-build indexes. - Generate topic pages at build time, never runtime.
Speed
- Hover prefetch (5-line script or Astro prefetch).
- One small CSS file beats over-preloading.
- Native View Transitions API — no framework.
Lists / search / deploy
- <500 paginate · 500–10k clusterize.js or
content-visibility· 10k+ TanStack Virtual. - <1k pages: Pagefind / Fuse.js. 10k+: Meilisearch / Typesense.
- Assets:
public, max-age=31536000, immutable. HTML:max-age=0, must-revalidate. - Images: WebP/AVIF, width+height, lazy+async. Fonts: self-host,
font-display:swap. - Web Worker for 100k-row JSON filter.
deferscripts. Minify.
document.getElementById("list").addEventListener("click", (e) => {
const item = e.target.closest("[data-id]");
if (item) handleClick(item.dataset.id);
});
7 · Copy-paste AI prompts
A · Scaffold. Astro, Markdown in /content/, one page per topic at /topics/[slug]/index.html, min CSS, zero client JS except search, hover prefetch, static host.
B · Virtual list. TanStack Virtual or vanilla. 50,000+ rows. Delegation. 60fps. Under 50MB RAM.
C · Pagefind. Do not load the index on first paint. Init on search focus. No external API.
D · Audit. JS size, DOM count, unused CSS, lazy images, cache headers, Brotli, listener count. Fix over-threshold items.
E · Migrate 30k-line HTML. URL per topic, extract CSS/JS, Astro or 11ty, paginate/virtualize, CDN.
Hover prefetch. Vanilla: hover on internal a injects link[rel=prefetch], skip duplicates.
Delegation. #topic-list parent, hundreds of child buttons, one listener.
Instant nav. Fetch HTML, swap main, pushState, prefetch on hover, degrade if JS is off.
8 · Performance checklist
- CDN serving Brotli (or gzip) for HTML/CSS/JS/SVG.
- WebP/AVIF + width/height +
loading="lazy". - Self-hosted fonts,
font-display: swap, preload only above-fold weights. - Hashed assets immutable one year. HTML revalidate.
- Heavy parse → Web Worker. Progressive enhancement: readable with JS off.
- Service worker only if offline is a real requirement.
Final recipe: Astro + Markdown/MDX + static HTML + Pagefind + tiny CSS + minimal JS + pagination/virtualization + lazy + prefetch + cache + CDN.
9 · Fluid CSS — less code, every screen
- clamp(min, preferred, max) for font, padding, gap. Example
font-size: clamp(1rem, 2.5vw, 1.5rem). - Pair with
min()/max(). Container max:min(100%, 600px). - Images:
aspect-ratio: 16/9; object-fit: cover; max-width: 100%; height: auto; - Viewport:
dvh/svh/lvh— not rawvh(mobile chrome). - Container queries when supported — style the component, not the viewport.
- Logical props:
margin-inline,padding-block,width: fit-content, gridauto-fit + minmax().
10 · Faster UI without React state
- Hover, checkbox +
:checked/:has(),details, CSS transitions for open/close — notuseState. useReffor focus, measure, DOM, timers (no re-render).- Composition over state. Uncontrolled children. Do not lift state high.
- Skip state for modals/tooltips/animations CSS can do.
- If state is required: keep it local.
useMemo/useCallbackonly after profiling. - External store only for truly global data. Result: fewer re-renders, snappier low-end pages.