Bagisto Hosting

Speed Up Your Store with the Speculation Rules API

Updated 3 July 2026

Fast websites are not just about quicker servers. They are about reducing the work the browser has to do after every click.

Traditional navigation waits until the user clicks before starting the next page.

The Speculation Rules API lets the browser prepare pages before navigation happens.

This guide shows how to use it Bagisto way to make page transitions feel almost instant.

 

Why Your Browser Waits Too Long

Most stores treat navigation as work that starts on click.

The browser waits for intent, then runs the request, download, parse, render, and paint chain.

Every step after the click, while the shopper stares at a loading page.

It feels unavoidable because “that is how the web works.” That feeling is the trap.

 

How Bagisto Solves It

Bagisto ships native Speculation Rules support in its storefront.

The admin can enable prerendering, and the browser renders the likely next page during hover.

By the time the shopper clicks a product tile, the product page is already built and ready.

The result is exactly the reverse of the three problems above-

The head start is used, vitals improve, and each hop feels instant.

You can apply the same pattern to any store. Here is how.

 

The Solution: Load Before the Click

You almost never need the next page to load at click time.

You need it ready by click time. Those are different problems.

You solve it with a tiny JSON block in your page <head>.

The browser reads it, watches every link, and prepares the one that match.

The rest of this guide is about generating that JSON safely and making it configurable.

 

Strategy 1 – Prefetch the resources

Prefetch quietly downloads the next page’s HTML and assets in the background.

The bytes wait in the browser cache, so the click skips the network round-trip.

It is cheap and low-risk, and it should be your default for category and search links.

Strategy 2 – Prerender the whole page

Prerender goes further and builds the entire next page invisibly, off-screen.

On click, the browser swaps the ready page in, so navigation is effectively instant.

It costs more CPU and memory, so reserve it for high-intent links like product pages.

Tuning Eagerness for Better Performance

Eagerness determines when the browser starts prefetching or prerendering a matching page.

Conservative – waits for stronger user intent, minimizing unnecessary requests and resource usage.

Moderate – balances performance and efficiency, making it a good default for most stores.

Eager – starts speculation as early as possible for the fastest navigation at the cost of higher CPU, memory, and server usage.

 

Build the rules in code

Do not hardcode the JSON. Build it so you can toggle strategies and exclude pages.

Bagisto does this in one method; here is the same idea, generalized for any store.

Then render it into the <head> behind a master switch you can flip off instantly.

JSON_UNESCAPED_SLASHES keeps URL patterns like /checkout/* intact and readable.

 

Always exclude your dynamic pages

This is the safety step you cannot skip.

Never prerender pages that change state or are personalized to one user.

Prerendering a link like below could fire the action before any click.

Add these to your ignore list from day one:

  • Checkout, cart, and payment URLs
  • Login, register, and account pages
  • Logout and action links like add to cart, wishlist, and compare

Each exclusion becomes a not condition in the rules.


This rule prerenders matching pages except checkout, cart.

Excluded prerender pages

Chrome DevTools confirms that checkout and cart URLs are recognized by the browser but are not speculatively loaded.

Impact on Navigation Performance

Here is the detailed in practical presentation of speculation rules api effect on page load time.

Category Page Navigation

Without Speculation rule load time ~ 1.5s

mens-category-before-speculation

With Speculation rule load time ~ 750ms

mens-category-after-speculation

Product Page Navigation

Without Speculation rule load time ~ 1s

product-before-speculation

With Speculation rule load time ~ 550 ms

product-after-speculation

Speculation API reduced navigation time nearly by half by prefetching pages during hover, making page transitions fast

Key takeaways

The browser can do your navigation work early. Let it.

1. Click-time loading wastes the head start hover already gives you.

2. Prefetch is cheap; prerender is instant; both cut real wait time.

3. Eagerness is your dial between speed and server or device cost.

4. Never prerender cart, checkout, account, or action URLs.

5. Verify with View Source, DevTools Preloading.

 

Thank You for Reading!

You now have everything you need to implement the Speculation Rules API.

Deliver faster, smoother navigation in your Laravel or Bagisto storefront.

If you have questions, suggestions, or feedback, we’d love to hear from you.

Leave a comment below, and we’ll be happy to help.

Happy speculating, and may every click feel instant!

You can also explore our Bagisto Extensions.

If you are planning to build with Laravel, consider hiring laravel developers. 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project




    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home