Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add eagerness support for prefetch() #13405

Merged
merged 7 commits into from
Apr 2, 2025

Conversation

Marocco2
Copy link
Contributor

@Marocco2 Marocco2 commented Mar 12, 2025

Changes

  • What does this change?

New PrefetchOptions param eagerness that can be explicitly stated for prefetch() function.

Usecase: letting a browser manage when a page should be prerendered will simplify web site code compared to default behavior (no eagerness passed will automatically default to immediate, causing headcaches if you want to use FIFO strategy available for moderate and conservative args)

Reference doc: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/speculationrules#eagerness

Testing

No tests added, as there weren't for PrefetchOptions

Docs

/cc @withastro/maintainers-docs

prefetch() doc should be updated accordingly to notify users a new option to be passed on

Copy link

changeset-bot bot commented Mar 12, 2025

🦋 Changeset detected

Latest commit: 01ee0d0

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 12, 2025
Copy link

codspeed-hq bot commented Mar 12, 2025

CodSpeed Performance Report

Merging #13405 will not alter performance

Comparing Marocco2:feat/prefetch-eagerness (01ee0d0) with main (7185491)

Summary

✅ 6 untouched benchmarks

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @Marocco2. This is a new feature, so it requires some updates in our docs. Can you do that? Let us know if you have time, we plan a release next week

@Marocco2
Copy link
Contributor Author

Thank you for your contribution @Marocco2. This is a new feature, so it requires some updates in our docs. Can you do that? Let us know if you have time, we plan a release next week

Thanks for replying! I'll check in these days what to do. Do you have any pipelines on how to add docs?

@ematipico
Copy link
Member

Docs PR should be sent to withastro/docs repository. This is the page you want to update: https://docs.astro.build/en/guides/prefetch/

@Marocco2
Copy link
Contributor Author

Added docs here: withastro/docs#11250
Hopefully I'll get required changes ASAP

@github-actions github-actions bot added the semver: minor Change triggers a `minor` release label Mar 21, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@Marocco2 Marocco2 requested a review from ematipico March 21, 2025 14:22
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing this feature! I'm sure people will appreciate this new option!

Here's my suggestion for an updated changeset based on the final docs. (Note that it doesn't have to be identical to docs, or explain the whole feature in detail -- usually it focuses more on the benefits, and gives people enough information to know whether they are interested in learning more).

Take from it what you like!

Co-authored-by: Sarah Rainsberger <[email protected]>
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for docs, assuming nothing changes in the feature! (Docs PR is all approved and ready to go, too.) 🚀

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Marocco2

@ematipico ematipico merged commit 21e7e80 into withastro:main Apr 2, 2025
27 of 28 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants