Skip to content

Speculation Rules API #754

Closed
Closed

Description

@BearCooder

Description

The Speculation Rules API is designed to improve performance for future navigations. It targets document URLs rather than specific resource files, and so makes sense for multi-page applications (MPAs) rather than single-page applications (SPAs).

The Speculation Rules API provides an alternative to the widely-available feature. It provides many improvements over these technologies, along with a more expressive, configurable syntax for specifying which documents should be prefetched or prerendered.

Specification

https://wicg.github.io/nav-speculation/speculation-rules.html

Additional Signals

Webkit: WebKit/standards-positions#54
Mozilla: mozilla/standards-positions#620

Tests:
https://wpt.fyi/results/speculation-rules?label=master&label=experimental&aligned&q=speculation

Info about:

Activity

  1. domenic commented on Oct 7, 2024

    @domenic
    Member

    Oh, very cool to see this posted.

    As one of the spec maintainers and Chromium engineers on this feature, I think it's important to emphasize that speculation rules is a surface API that triggers (as of now) two larger features: prefetching, or prerendering. Those are specified in https://wicg.github.io/nav-speculation/prefetch.html and https://wicg.github.io/nav-speculation/prerendering.html. So just implementing the speculation rules spec by itself doesn't help; you'd need to implement one or both of those.

    If the parties involved don't want to accept everything into Interop 2025, I think accepting speculation rules + prefetching (omitting prerendering) would be a good compromise. As of October 1, speculation rules prefetch is used on ~12% of page loads, and this number is likely to go up a good chunk more as Cloudflare's Speed Brain deployment continues. Speculation rules prerender, although it's more dramatic and certainly well-loved among web developers, isn't seeing as-high adoption numbers. And working prefetch this year would be good groundwork if browsers wanted to tackle prerender the next year.

  2. ryantownsend commented on Oct 7, 2024

    @ryantownsend

    @domenic I agree prefetch-only is a really good compromise on scope but one thought on this: would it be wise for them to treat prerender rules asif they were declared as prefetch?

    In my view, prerender is a stronger signal that a URL/href will be the next page (I know we have eagerness for that too) so they could depend on effectively downgrading prerender where it's not supported.

    If browsers weren't to do this, then we'll end up having to conditionally serve Speculation Rules to different browsers (possibly needing UA sniffing?), which is far from ideal.

  3. domenic commented on Oct 8, 2024

    @domenic
    Member

    I agree that treating prerender as prefetch is reasonable. We've thought of doing that at times in Chromium (e.g. if limits are hit), but haven't as of yet.

  4. wpt-interop commented on Feb 13, 2025

    @wpt-interop
    Collaborator

    Thank you for proposing Speculation Rules API for inclusion in Interop 2025.

    We wanted to let you know that this proposal was not selected to be part of Interop this year.

    On behalf of the entire Interop team, thank you for submitting this proposal for consideration. We got many more proposals than we could include in this year's project, necessitating some difficult choices. Please note this should not be taken as a comment on the technology as a whole, or our willingness to consider it for Interop in the future. We appreciate the work you put into your proposal, and would welcome your participation in future rounds of Interop.

    For an overview of our process, see proposal selection. Thank you again for contributing to Interop 2025.

    Posted on behalf of the Interop team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    focus-area-proposal

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions