Add support for prerender_until_script mode and origin trial token#2512
Add support for prerender_until_script mode and origin trial token#2512danielpazwp wants to merge 1 commit into
Conversation
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @dpazwp. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
c2d6231 to
fb8d261
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #2512 +/- ##
==========================================
+ Coverage 69.29% 69.40% +0.10%
==========================================
Files 90 90
Lines 7723 7753 +30
==========================================
+ Hits 5352 5381 +29
- Misses 2371 2372 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fb8d261 to
f9a5fbe
Compare
Summary
Fixes #2362
This pull request adds support for the experimental
prerender_until_scriptspeculation rules mode, which serves as a middle ground between prefetching and full prerendering (downloading resources and starting layout but pausing before running blocking script elements).It also adds native support for configuring the Google Chrome Origin Trial token for this feature, allowing site owners to test it in production with real visitors.
Relevant technical choices
prerender_until_scriptto the allowed mode list ($mode_allowlist) in the Core speculation rules API and updated relevant Docblocks.prerender_until_script, we automatically apply exclusions for links marked with.no-prefetch(since prefetching is part of prerendering) and.no-prerender(since prerendering until script is a form of prerendering).origin_trial_tokento the Speculative Loading settings section under Settings > Reading. The token is sanitized usingsanitize_text_field().plsr_print_origin_trial_meta_tag()hook callback towp_headat priority 1 to output<meta http-equiv="origin-trial" content="...">as early as possible in the head tag, but only if a token is configured, speculative loading is enabled, and the speculation mode is set toprerender_until_script.How to test
1. Enable the Experimental Chrome Flag (Local testing)
Since this feature is not yet fully enabled by default in all Chrome versions, you must enable the flag locally:
chrome://flags/#prerender-until-script.2. Configure WordPress Settings
3. Verify Frontend Behavior
<script type="speculationrules">tag is generated with"prerender_until_script"rules, and (if configured) the<meta http-equiv="origin-trial" content="...">tag is present in the<head>.F12), go to the Application tab, and select Speculative loads on the left menu.Use of AI Tools
This pull request was co-authored using Antigravity (a coding assistant designed by Google DeepMind).