eCommerce Fastlane

Free every Thursday · 61,308 Readers

Fastlane Insider Newsletter: What's working for Shopify in the AI era?

Speculation Rules at Shopify

Steve Hutt
Published:
August 29, 2025
speculation-rules-at-shopify

We all love quick and snappy online shopping experiences. Fast navigations from one product page to the next reduce friction and allow people to find all the products they want in that store.

To achieve that, one could implement a smart mechanism that predicts where the user is likely to go and preloads those pages earlier. Solutions like that do already exist, but have historically required custom JavaScript to work. The Speculation Rules API aims to provide a native way of achieving the same effect.

After experimenting with the API for over a year, we finally released our platform-wide configuration back in June 2025.

Read on to learn what this feature is all about and how it made Shopify stores up to 180ms faster across all loading metrics in supported scenarios.

The Speculation Rules API
Jump to heading


The Speculation Rules API is essentially configuration developers send to the browser. That configuration takes form as a JSON that tells the browser:

  • The speculative loading techniques it should use – prefetch or prerender.
  • Which links it should target – specific lists, URL patterns, or even CSS selectors.
  • How aggressive it should be – through the eagerness setting.

There are a lot of different scenarios that can be configured. You can learn more about them in the MDN documentation.

It is all about trade-offs
Jump to heading


It may be tempting to make the browser immediately prerender all of the links on the page. However, there are two important trade-offs that you need to consider when preparing the configuration.

The first one has to do with eagerness. The more aggressive it is, the bigger the risk of loading the page that a visitor won’t ever visit in the current session. This wastes their data and may slow down the loading of the current URL. There can also be cases where the cached content becomes stale if you fetch it early.

The second one is related to the preloading strategy. While prerender is very powerful, it also executes all scripts (including analytics). This can lead to overreporting in terms of page views and other related events. prefetch on the other hand is very safe, but only the initial HTML response gets cached, limiting the performance improvements.

Speculative loading for Liquid storefronts
Jump to heading


Our main goal was to come up with a Speculation Rules API configuration that we can enable for the entire platform. This proved to be a proper challenge that required many iterations. There are multiple routes that you definitely don’t want to speculate upon like a logout link. We also encountered a few browser bugs that had to be fixed and released before moving further.

Nonetheless, I’m happy to report that all of the Liquid-based storefronts have been benefiting from the speculative loads since late June.

In terms of the implementation, we settled on sending the configuration via the Speculation-Rules header in the main HTML response:

Screenshot of the developer tools with the Speculation-Rules header highlighted in the main HTML response. It points to an external JSON file that contains all of the rules.
Speculation-Rules header highlighted in the main HTML response. It points to an external JSON file that contains all of the rules.

At the time of writing this article, our rules are configured to prefetch all of the key safe routes with a conservative eagerness. This means the browser will prefetch the link right when the user presses down the mouse button or places their finger on the screen. All of that without waiting for the release action that is required to trigger the actual navigation.

It’s worth noting that stores can still define their own rules via the

Choose a language