web-stories-wp icon indicating copy to clipboard operation
web-stories-wp copied to clipboard

Implement speculative prerendering (Speculation Rules)

Open swissspidy opened this issue 11 months ago • 0 comments

Feature Description

The WordPress core performance team has recently launched the Speculation Rules feature plugin, which leverages the Speculation Rules API to enable dynamically prefetching/prerendering URLs based on user interaction.

See https://developer.chrome.com/docs/web-platform/prerender-pages for an explainer blog post.

This made me wonder how we could implement this API in Web Stories as well.

Some possibilities:

  • In the Web Stories dashboard or the "All Stories" page:
    • Preload the editor when hovering over the story edit link
    • Maybe even preload the editor when hovering over the link to create a new story (if auto-drafts are not an issue)
    • Preload the story permalink when hovering over the link to view the story
  • On the frontend
    • Support preloading the archive page or individual stories upon hovering

Implementation-wise:

  • Leverage the Speculation Rules plugin if it is active
  • If the plugin is not active:
    • Either add a new SpeculativePrerendering service.
    • Alternatively, add a new HasPrerendering interface so every relevant service can indicate preloading/prerendering rules for it.

A dedicated service is probably easiest, no need to overcomplicate things.

Alternatives Considered

Additional Context

swissspidy avatar Mar 12 '24 13:03 swissspidy