Skip to content

Support prefetch in core #754

@bluwy

Description

@bluwy

Summary

Deprecate @astrojs/prefetch and provide first-class prefetch support in Astro.

Background & Motivation

With the introduction of View Transitions, it includes partial prefetching code for snappy navigation between pages. We can take this opportunity to support prefetching in core, and share the prefetch behaviour with View Transitions.

I've started an implementation before an RFC as the initial plan was to simply move @astrojs/prefetch to core. However, it would also be a good time to polish up and extend the API.

Goals

  • An option to enable prefetching
  • Enable prefetching via an attribute/hint
  • Enable prefetching for all links by default (required by View transitions)
  • Disable prefetching if all links are enabled by default
  • Different prefetching strategies (click, hover, viewport, etc)
  • Only add JS if using prefetching

Non-Goals

  • Prefetch cache invalidation (Browser relies on cache control)
  • Prefetch external links

NOTE: Stage 2 does not mention solution details, but I've written one in the discussion: withastro/astro#8951

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Implemented

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions