diff --git a/sx/sx/plans.sx b/sx/sx/plans.sx index 2798e7a..a31d6b4 100644 --- a/sx/sx/plans.sx +++ b/sx/sx/plans.sx @@ -603,7 +603,8 @@ (~doc-section :title "Context" :id "context" (p "Phase 3 of the isomorphic roadmap added client-side routing with component dependency checking. When a user clicks a link, " (code "try-client-route") " checks " (code "has-all-deps?") " — if the target page needs components not yet loaded, the client falls back to a server fetch. This works correctly but misses an opportunity: " (strong "we can prefetch those missing components before the click happens.")) - (p "The page registry already carries " (code ":deps") " metadata for every page. The client already knows which components are loaded via " (code "loaded-component-names") ". The gap is a mechanism to " (em "proactively") " resolve the difference — fetching missing component definitions so that by the time the user clicks, client-side routing succeeds.")) + (p "The page registry already carries " (code ":deps") " metadata for every page. The client already knows which components are loaded via " (code "loaded-component-names") ". The gap is a mechanism to " (em "proactively") " resolve the difference — fetching missing component definitions so that by the time the user clicks, client-side routing succeeds.") + (p "But this goes beyond just hover-to-prefetch. The full spectrum includes: bundling linked routes' components with the initial page load, batch-prefetching after idle, predicting mouse trajectory toward links, and even splitting the component/data fetch so that " (code ":data") " pages can prefetch their components and only fetch data on click. Each strategy trades bandwidth for latency, and pages should be able to declare which tradeoff they want.")) (~doc-section :title "Current State" :id "current-state" (div :class "overflow-x-auto rounded border border-stone-200 mb-4" @@ -638,11 +639,94 @@ (td :class "px-3 py-2 text-stone-700" (code "find-matching-route") " matches pathname to page entry") (td :class "px-3 py-2 font-mono text-sm text-violet-700" "router.sx")))))) + ;; ----------------------------------------------------------------------- + ;; Prefetch strategies + ;; ----------------------------------------------------------------------- + + (~doc-section :title "Prefetch Strategies" :id "strategies" + (p "Prefetching is a spectrum from conservative to aggressive. The system should support all of these, configured declaratively per link or per page via " (code "defpage") " metadata and " (code "sx-prefetch") " attributes.") + + (div :class "overflow-x-auto rounded border border-stone-200 mb-4" + (table :class "w-full text-left text-sm" + (thead (tr :class "border-b border-stone-200 bg-stone-100" + (th :class "px-3 py-2 font-medium text-stone-600" "Strategy") + (th :class "px-3 py-2 font-medium text-stone-600" "Trigger") + (th :class "px-3 py-2 font-medium text-stone-600" "What prefetches") + (th :class "px-3 py-2 font-medium text-stone-600" "Latency on click"))) + (tbody + (tr :class "border-b border-stone-100" + (td :class "px-3 py-2 font-semibold text-stone-800" "Eager bundle") + (td :class "px-3 py-2 text-stone-700" "Initial page load") + (td :class "px-3 py-2 text-stone-700" "Components for linked routes included in " (code "