Who doesn't dream of the instant page content loading for the site’s visitors? If you are also one belonging to this group, then get ready for news.
Google has long been trying to teach developers to prerender and prefetch important pages and resources. Speculation Rules API seems to be a standard for these approaches. We see it really works, and it has become a trend in page speed area 2024.
We certainly couldn't walk through it. Introducing Speculation Rules module for Magento 2.
It is now available for free. Moreover, the new module has become a part of the Page Speed extension. You can use modules separately and still enjoy the benefits of Speculation Rules API, boosted performance, and enhanced user satisfaction.
Now we are going to discuss them in detail. Join us.
The Speculation Rules API is a JSON-defined API by Google. Its main purpose is to eventually improve the performance of web page loading, yet through a specific strategy - speculative loading.
A little about how it works
Speculative loading is about performing navigation actions like fetching resources or rendering documents before they are needed or visited. The approach is based on predictions as to what pages the visitor is most likely to move next.
The Speculation Rules API targets document URLs rather than specific resource files. In a simple way, by prerendering frontend URLs linked on the page, the API provides predictive hints to the browser. In a complex way, the API includes a configurable syntax for specifying which documents should be prefetched or prerendered. With a structure defined in JSON format within a script type="speculationrules", developers can articulate rules for both prerendering and prefetching.
How it will result
Using the Speculation Rules API approach is supported in Chromium-based browsers such as Chrome, Edge, or Opera. The next effects and benefits will remain available:
- Rendering can be achieved much more quickly.
- More seamless web browsing.
- Improved page load times and enhanced customer experience.
- Boosted Core Web Vitals scores for your Magento 2 websites. In particular with the prerendering, the reduced CLS (because CLS load happens before the initial view), and improved INP (because the load should be completed before the user interacts) are expected.
This was a response to your possible request - Why use the new module on your website? Let’s see more about it.
Here’s the new M2 Speculation Rules module
Now, the Magento 2 Speculation Rules module can be enabled in your stores.
The extension comes with a simple configuration:
- It allows you to enable/disable the module per store view.
- It has a text area to help you change predefined Speculations Rules.
The module takes the form of a JSON structure that determines what resources should be prefetched or prerendered by the browser. This is part of the Speculation Rules API.
That's not all
Good news. In May we released the 1.7.32 version of the Page Speed extension. We're excited to include the M2 Speculation Rules module as its part.
As you might see, we keep working on improvements in page time loading. It has become a web performance trend this year, so we can't stop here.