Using Speculation Rules for instant page loads

Boost your performance with Speculation Rules in Hyvä 1.3.7

Speculation Rules is a new feature available in 73% of all browsers that allows users to boost performance on multi-page applications.

Speculation Rules enables users to define which URLs should be pre-rendered when hovering or clicking on them, resulting in instant page loads.

By using a code snippet, users can set conditions for preloading URLs, such as hover intent or click actions. Speculation Rules can be enabled in the latest version of Hyvä Themes and is ideal for static pages. It improves user experience and can boost Core Web Vitals scores.

Speculation Rules are added as an experimental feature in Hyvä Theme module version 1.3.7.

You can enable it from you Magento admin: Hyvä Themes > Experimental > Experimental Features > Enable Preloading Speculation Rules

Read more:

Example snippet:

This is the speculation rule config we use on this website at the time of writing. You can see exact matches, wildcards and regular expressions can be used:

Source: Document, optional?

Update 29 April, 2024

The official spec isn't stable yet (All features are marked 'experimental' in the MDN web docs), so the way the above script works might change in the future.

At the time of writing, it turns out many browsers still expect the "Source" definition, while the spec says it is optional when using the "where" key. Not setting the "source": "document" key will throw the error "A rule must have a source".

We have therefore added the "source" key to the snippet above and will probably update our implementation in the Hyvä Theme in the near future.

Share

Related Posts

Get Hyvä for your store

Build your ideal setup in just a few clicks, on your terms.

Step of 2 Your store Your setup

This domain will be linked to your Hyvä licenses.

Please enter a valid domain (e.g. mystore.com)

Recommended
Hyvä Commerce

Everything you need to build your store, your way.

Hyvä Commerce €3,000/year
Hyvä Theme, Checkout and UI in one complete setup
Fast and flexible content management with Hyvä CMS
Improved admin experience, built for speed and ease
Tools for performance, scalability and control
Upgrade to Hyvä Enterprise for full Adobe Commerce support (includes Hyvä Commerce) /year
Learn more
Hyvä Commerce Recommended
Build your own
Build your own
Hyvä Theme
Hyvä Theme Included with all Hyvä products.
Free
Hyvä UI
Hyvä UI

Copy. Paste. Done. Enhance your design and coding workflow with a library of modern, reusable components that make building beautiful, consistent pages effortless.

€250
Hyvä Checkout
Hyvä Checkout

Faster checkout. Happier customers. Reduce friction and boost conversions with a lightning-fast, fully customisable checkout that's easy to integrate.

€1,000
Choose your Update & Support plan
Hyvä Enterprise
Hyvä Enterprise

Full Adobe Commerce support, including Hyvä Commerce. Unlock Adobe Sensei capabilities, content staging, B2B functionality, loyalty features and more.

€7,500/year
Choose your Update & Support plan
Total: