/** * Issue #192 — Hover prefetch helper * * Self-contained IIFE that watches `mouseover` events bubbling from * internal `` anchors and issues a one-shot * `` per unique anchor. The browser * cache services the subsequent full-reload navigation, so most * above-the-fold links feel instantaneous without requiring a SPA * runtime. * * Design choices (locked to keep the payload tiny — target ≤500 bytes * minified + gzipped): * * 1. **WeakSet-based dedup**: we never attach per-anchor listeners; * we use a single `document`-level capture listener and stamp * each anchor we've seen into a `WeakSet`. Anchors removed from * the DOM collect automatically. * * 2. **Scope: same-origin `/...` paths only**: we deliberately skip * absolute URLs, `mailto:`, `tel:`, `javascript:`, hash-only * fragments, and `#`-on-same-page links. The `a[href^="/"]` * selector implicitly covers this and avoids a surprise * cross-origin DNS lookup. * * 3. **Opt-out per-link via `data-no-prefetch`**: mirrors Next.js' * `prefetch={false}` ergonomics while being framework-agnostic — * works with plain `` and with Mandu's `` component. * * 4. **`as="document"` hint**: the correct token for HTML documents * that will be navigated to via a subsequent click. Without it * Chrome 121+ logs a `rel=prefetch as=missing` warning. * * 5. **Capture phase + `passive: true`**: listening in the capture * phase catches the event before any app-level bubble handlers * can cancel it (defensive against apps that `stopPropagation` * on ``). `passive` ensures we can never accidentally block * scroll. * * 6. **Inline, not external bundle**: the helper is under 1KB and * emitting it as a ``;