web-stories-wp
web-stories-wp copied to clipboard
Implement speculative prerendering (Speculation Rules)
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.
- Either add a new
A dedicated service is probably easiest, no need to overcomplicate things.