All posts
Web Development
3 min read• 12/2/2026

Instant Page Loads with Native Speculation Rules

Eliminate hydration bottlenecks and client routing overhead. Learn how to implement native browser Speculation Rules without inflating your server compute.

Share X LinkedIn

Tip: use ← / → to browse posts.

Instant Page Loads with Native Speculation Rules
## Beyond Client-Side Routing Gymnastics For over a decade, frontend engineering teams have chased the holy grail of zero-latency page transitions. We embraced gigantic Single Page Application (SPA) bundles, pushed client-side hydration engines to their limits, and filled our codebases with predictive link-prefetching libraries that clog the main thread. Despite this complexity, real-world web performance remains mediocre. Client-side hydration often blocks user interactions, prefetching scripts devour mobile data plans, and complex state lifecycles trigger subtle memory leaks during extended browser sessions. Modern browsers now provide a native, platform-level solution: the **Speculation Rules API**. By offloading pre-rendering directly to the browser engine itself, we can deliver genuine instant navigations—0ms perceived latency—without shipping megabytes of JavaScript routing logic. ## What Makes Speculation Rules Different? Traditional resource hints like `<link rel="prefetch">` merely download the HTML document into the HTTP cache. When the user eventually clicks the link, the browser must still parse the HTML, fetch associated CSS and JavaScript, execute framework runtimes, and construct the DOM tree. In contrast, the Speculation Rules API allows you to instruct the browser to execute a full background *prerender*. The browser creates an invisible, offscreen tab instance, parses the entire document, builds the DOM, downloads assets, and runs initial JavaScript execution. When the user clicks the target link, the active tab simply swaps the prerendered instance into place instantly. There is no hydration delay, no layout shift, and no rendering pause. It is indistinguishable from native desktop software. ```html <script type="speculationrules"> { "prerender": [ { "source": "list", "urls": ["/checkout", "/pricing"], "eagerness": "moderate" }, { "source": "document", "where": { "and": [ { "href_matches": "/*" }, { "not": { "href_matches": ["/api/*", "/logout", "/admin/*"] } }, { "not": { "selector_matches": ".no-prerender" } } ] }, "eagerness": "conservative" } ] } </script> ``` ## Eliminating Compute Blowouts: The "Eagerness" Strategy Prerendering complete pages in the background is incredibly fast, but if implemented carelessly, it will rapidly inflate your origin server compute costs and exhaust user bandwidth. The key to scalable implementation is tuning the `eagerness` setting: * **Immediate:** The browser starts prerendering the moment the rule is parsed. Use this exclusively for high-probability next steps (e.g., an onboarding flow where 98% of users go from Step 1 to Step 2). * **Moderate:** The browser prerenders only when the user hovers over a link for more than 200ms or moves their pointer toward it. This filters out accidental passes and drastically cuts unnecessary origin hits. * **Conservative:** Prerendering triggers only on `mousedown` or touch-start. Even this tiny 50–100ms head start before click completion is enough to shave perceived rendering delays down to zero. ### Protecting Session State and Analytics Prerendering code runs client JavaScript in an invisible context. If your engineering team is not careful, this will duplicate your analytics pings and execute mutations before the user ever looks at the page. You must guard state-altering logic and telemetry triggers using the native Page Visibility and Activation APIs: * **Suppress Conversion Hits:** Never record page views or conversions inside your scripts until `document.prerendering` transitions to `false` via the `prerenderingchange` event. * **Avoid Destructive Actions:** Do not trigger auto-logout timers, token refreshes, or destructive mutations inside any page capable of being targeted by a speculation rule. * **Validate Cache-Control Headers:** Always deliver speculation targets with explicit, immutable cache headers for static chunks, alongside strict `Vary: Accept-Encoding, Sec-Purpose` headers on HTML endpoints. ## The Return to Clean Multi-Page Architectures With native Speculation Rules, the architectural justification for giant, complex client-side routing monoliths evaporates. You can build completely server-rendered web applications using simple modern frameworks (Astro, Next.js App Router with RSC, Remix, or Phoenix LiveView) and achieve navigation speeds that outpace the most meticulously tuned SPAs. Stop rebuilding the browser engine in user-space JavaScript. Hand the navigation problem back to the browser platform, configure your speculation boundaries responsibly, and give your users instant page loads without the overhead.
web performance
speculation rules
frontend
browser apis
Share X LinkedIn

What clients say

Real reviews from founders and teams we've shipped with.

5.0 · 6 reviews
"From concept to launch in weeks. The browser project set a new bar for our team."
Vikram J.
Founder, Finup Browser
"Grok integration for real-time X data was the differentiator our product needed. Fast to prototype, faster to ship."
xAI Integration
Grok · Real-time X data
"Our mobile app in React Native + Expo shipped to both stores in a week. Reviews are glowing."
Diego A.
Founder, Kite Health
"My personal brand finally has a home worthy of the work. Elegant, fast, timeless."
Rie A.
Creator, rieasajan.com
"AI SDK integration for streaming tool-calls was textbook. Our agents finally feel alive."
Bilal H.
AI Lead, Agentworks
"A luxurious real-estate experience. Buyers actually enquire — that's the real proof."
Omar H.
Director, Future Dubai Homes