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

Implement speculative loading considerations for safer behavior #1784

Merged
merged 8 commits into from
Jan 9, 2025

Conversation

felixarntz
Copy link
Member

Summary

Fixes #1157

Relevant technical choices

  • Disables speculative loading completely for logged-in users.
    • This is in line with the already present exclusions for wp-admin and wp-login.php.
  • Excludes URLs with query parameters when pretty permalinks are enabled and disables speculative loading completely by default if pretty permalinks are disabled.
    • A filter can be used to opt in to speculative loading even without pretty permalinks. In this case the query parameter exclusion does not apply, so it is more risky - hence it's opt-in for such sites.
  • Changes the /wp-login.php URL exclusion to /wp-*.php, as there are other files in the WordPress root directory that may be directly accessed and are safer to exclude, e.g. wp-activate.php and wp-signup.php (relevant mostly for Multisite).
    • Of course we could instead exclude the specific URLs, but a wildcard for this is easier to maintain and has no adverse effects.

@felixarntz felixarntz added [Type] Enhancement A suggestion for improvement of an existing feature [Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) labels Jan 9, 2025
@felixarntz felixarntz added this to the speculation-rules n.e.x.t milestone Jan 9, 2025
@felixarntz felixarntz requested a review from westonruter January 9, 2025 22:07
Copy link

github-actions bot commented Jan 9, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: felixarntz <[email protected]>
Co-authored-by: westonruter <[email protected]>
Co-authored-by: AntonyXSI <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

The readme should probably be updated to note the new restrictions, in particular for the authentication requirement.

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.48%. Comparing base (4693bee) to head (4898dfc).
Report is 12 commits behind head on trunk.

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #1784      +/-   ##
==========================================
+ Coverage   57.42%   57.48%   +0.06%     
==========================================
  Files          84       84              
  Lines        6506     6516      +10     
==========================================
+ Hits         3736     3746      +10     
  Misses       2770     2770              
Flag Coverage Δ
multisite 57.48% <100.00%> (+0.06%) ⬆️
single 34.51% <60.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@felixarntz felixarntz requested a review from westonruter January 9, 2025 22:53
@felixarntz felixarntz merged commit b6e5c5a into trunk Jan 9, 2025
16 checks passed
@felixarntz felixarntz deleted the enhance/1157-speculation-rules-considerations branch January 9, 2025 23:21
@westonruter westonruter mentioned this pull request Jan 25, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Speculative loading considerations
2 participants