Speculative load
RUMvision can collect information about speculative loading through the browser's Speculative Load Measurement API. This allows you to see which speculative navigations were started, which one was eventually used, and whether speculative preloads ended up being useful.
This is an opt-in feature. At the time of writing, the API is available through an Origin Trial. During this period, you can enable Speculative Load Measurement under Experiments in your domain's Features section.
The related dimensions and metrics can be used together to evaluate how effective your Speculation Rules are in real-world traffic.
Speculation data is collected when the browser exposes this information. As browser support and the underlying API are still evolving, these fields may not be available for every pageview.
Speculation dimensions
RUMvision currently exposes two dimensions for triggered speculative navigations. These can be used to distinguish different Speculation Rules, strategies and eagerness levels.
Speculation navigation tags
This dimension contains the tags and strategies associated with speculative navigations that were started by the browser.
When a developer-defined tag is available, RUMvision will expose that tag. The speculation type and eagerness are also represented as a combined value, for example:
prerender-until-script:eager
A single pageview can contain multiple values. RUMvision may also include a count variant when the same tag or strategy occurred multiple times during that pageview:
prerender_until_script+eager
prerender_until_script+eager:count=3
prerender-until-script:eager
prerender-until-script:eager:count=2
The value without :count= can be used as a regular filter or grouping dimension. The count variant provides additional information about how often that particular tag or strategy occurred within the pageview.
This can be useful when comparing different Speculation Rules. For example, a rule might frequently appear in Speculation navigation tags while rarely appearing as the actually used speculation.
Speculation navigation used
This dimension identifies the speculative navigation that matched the user's actual outgoing navigation.
When available, the dimension contains both the developer-defined tag and the corresponding speculation strategy. For example:
prerender_until_script+eager
prerender-until-script:eager
This makes it possible to filter specifically on speculative navigations that were actually used rather than merely started by the browser.
The dimension can also contain the following special values:
- none
The outgoing destination was known, but none of the triggered speculative navigations matched it. - unknown
The browser did not expose enough information to reliably determine which speculative navigation, if any, was used.
Combining Speculation navigation used with Speculation navigation tags can help identify rules that trigger frequently but rarely contribute to the navigation that visitors actually take.
Speculation metrics
In addition to dimensions, RUMvision collects several numeric metrics that describe the amount of speculative work performed by the browser.
Speculative navigations
The number of speculative navigations that were actually started by the browser during the pageview.
This should not necessarily be interpreted as the total number of candidates defined by your Speculation Rules. It represents the speculative navigations exposed by the Speculative Load Measurement API for that pageview.
A higher value is not automatically problematic. However, consistently high values combined with little successful usage can indicate that your Speculation Rules are too broad or aggressive.
Speculative preconnects
The number of speculative preconnects initiated by the browser.
This metric shows how much preconnect activity occurred, but does not indicate whether an individual preconnect was eventually beneficial.
When this number is unexpectedly high, inspect which origins are being preconnected to and whether those origins are commonly needed shortly afterwards.
Speculative preloads
The number of speculative preloads initiated by the browser.
This metric becomes especially useful when combined with Unused preloads. A high number of preloads is not necessarily wasteful if the resources are subsequently consumed.
Unused preloads
The number of speculative preloads that were not used.
This value is also reported as 0 when speculative preloads were present but all of them were used. This makes it possible to calculate an unused preload ratio:
unused preloads / speculative preloads
A consistently high ratio can indicate unnecessary speculative resource loading and therefore avoidable bandwidth usage.
Using Speculation Rules RUM data
The dimensions and metrics are most useful when combined rather than interpreted independently.
Evaluating navigation efficiency
Start with Speculative navigations to understand how many speculative navigations are being triggered.
You can then use Speculation navigation tags to determine which rules or strategies are responsible, and Speculation navigation used to see which of those strategies actually resulted in the visitor's navigation.
For example, when a pageview contains:
Speculative navigations: 10
Speculation navigation tags:
- prerender-until-script:eager
- prerender-until-script:eager:count=10
Speculation navigation used:
- prerender-until-script
one of the ten triggered speculative navigations matched the actual destination. The remaining nine speculative navigations were therefore not used.
If this pattern occurs frequently, consider reviewing the associated Speculation Rule. Depending on the use case, possible experiments include narrowing the rule scope, reducing the eagerness level, or testing another speculation type such as prefetch, prerender-until-script or prerender.
Finding inefficient speculation by template
Looking at Speculative navigations on its own tells you how many speculative navigations the browser started, but not whether that amount is appropriate for the page.
A useful next step is to combine this metric with a Template dimension. Different templates often expose very different numbers of possible next navigations. A product listing or search result page, for example, may contain many links and therefore trigger substantially more speculative navigations than a product detail page.
Once you have identified templates with a relatively high number of speculative navigations, use Navigation Tags to determine which rules and strategies are responsible. This dimension can contain both developer-defined tags and combined : values such as:
prerender_until_script:eager
You can then use Navigation Used to determine which speculative navigation matched the destination the visitor actually chose.
For example, imagine that product listing pages commonly show:
Template: Product listing
Speculative navigations: 6
Navigation Tags: prerender_until_script:eager
Navigation Used: none
This means that the browser started multiple speculative navigations on those pageviews, but none of them matched the navigation eventually taken by the visitor.
If this pattern occurs frequently for the same template, rule tag or strategy, the Speculation Rules may be broader or more aggressive than needed. Consider inspecting which links are eligible for speculation and whether the rule scope or eagerness level can be adjusted.
For comparison, another template may show fewer speculative navigations while more often exposing a real value in Navigation Used:
Template: Product detail Speculative navigations: 2 Navigation Tags: prerender_until_script:eager Navigation Used: prerender_until_script:eager
This does not automatically mean that two speculative navigations is the ideal amount, but it provides much stronger evidence that the speculation being initiated on this template corresponds with actual visitor behaviour.
Useful combinations to investigate include:
- Template + Speculative navigations
Find templates where browsers start relatively many speculative navigations. - Template + Navigation Tags
Identify which developer tags, speculation types and eagerness levels are responsible. - Template + Navigation Used
See whether speculative navigations on that template are actually matching visitor navigation. - Navigation Tags + Navigation Used
Compare rules that trigger frequently with the rules and strategies that ultimately result in a used navigation.
After changing a Speculation Rule, collect new RUM data and compare the same template and dimensions again. This makes it possible to determine whether reducing the rule scope, changing eagerness or using another speculation type actually improved real-world efficiency.
Evaluating preload efficiency
Use Speculative preloads together with Unused preloads to determine whether speculative loading is causing resources to be downloaded without being consumed.
For example:
Speculative preloads: 5 Unused preloads: 0
means that all measured speculative preloads were eventually used.
When the unused ratio is consistently high, inspect the affected pages and Speculation Rules before changing the implementation. A rule that is too broad or too eager can cause work to be performed for destinations that visitors rarely choose.
Comparing different strategies
The combined [type:eagerness] values make it possible to compare strategies such as:
prefetch:moderateprerender:eagerprerender-until-script:eager
Developer-defined tags can provide an additional layer of context. For example, you could tag rules based on where they are used, such as product cards, search results or primary navigation.
This allows you to identify which rules generate substantial speculative activity and which ones are most often associated with a successful navigation.
Validating changes with new RUM data
Speculation data should be treated as observational field data. It can identify inefficient patterns and affected parts of your site, but changes to your Speculation Rules still need to be made within your website or application.
After adjusting a rule, such as changing its eagerness, scope or speculation type, collect new RUM data and compare the resulting navigation usage and preload efficiency.
This iterative approach makes it possible to optimize Speculation Rules based on real visitor behaviour rather than relying only on local testing.
