From 558ea62ce83bacec4a2e0eb1a33322d1a8c3cb7e Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 8 Nov 2024 14:13:54 -0800 Subject: [PATCH 1/2] Improve docs in speculative loading plugin readme. --- plugins/speculation-rules/load.php | 2 +- plugins/speculation-rules/readme.txt | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/plugins/speculation-rules/load.php b/plugins/speculation-rules/load.php index 36d74d2c78..ad186c06b6 100644 --- a/plugins/speculation-rules/load.php +++ b/plugins/speculation-rules/load.php @@ -2,7 +2,7 @@ /** * Plugin Name: Speculative Loading * Plugin URI: https://github.com/WordPress/performance/tree/trunk/plugins/speculation-rules - * Description: Enables browsers to speculatively prerender or prefetch pages when hovering over links. + * Description: Enables browsers to speculatively prerender or prefetch pages to achieve near-instant loads based on user interaction. * Requires at least: 6.5 * Requires PHP: 7.2 * Version: 1.3.1 diff --git a/plugins/speculation-rules/readme.txt b/plugins/speculation-rules/readme.txt index 475ce96c85..9de308792d 100644 --- a/plugins/speculation-rules/readme.txt +++ b/plugins/speculation-rules/readme.txt @@ -7,26 +7,24 @@ License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Tags: performance, javascript, speculation rules, prerender, prefetch -Enables browsers to speculatively prerender or prefetch pages when hovering over links. +Enables browsers to speculatively prerender or prefetch pages to achieve near-instant loads based on user interaction. == Description == -This plugin adds support for the [Speculation Rules API](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API), which allows defining rules by which certain URLs are dynamically prefetched or prerendered based on user interaction. +This plugin adds support for the [Speculation Rules API](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API), which allows defining rules by which certain URLs are dynamically prefetched or prerendered. See the [Speculation Rules WICG specification draft](https://wicg.github.io/nav-speculation/speculation-rules.html). -By default, the plugin is configured to prerender WordPress frontend URLs when the user hovers over a relevant link. This can be customized via the "Speculative Loading" section under _Settings > Reading_. +By default, the plugin is configured to prerender WordPress frontend URLs when the user interacts with a relevant link. This can be customized via the "Speculative Loading" section in the _Settings > Reading_ admin screen. -A filter can be used to exclude certain URL paths from being eligible for prefetching and prerendering (see FAQ section). Alternatively, you can add the 'no-prerender' CSS class to any link (`` tag) that should not be prerendered. See FAQ for more information. +A filter can be used to exclude certain URL paths from being eligible for prefetching and prerendering (see FAQ section). Alternatively, you can add the `no-prerender` CSS class to any link (`` tag) that should not be prerendered. See FAQ for more information. = Browser support = -The Speculation Rules API is a new web API, and the functionality used by the plugin is supported in Chromium-based browsers such as Chrome, Edge, or Opera using version 121 or above. Other browsers such as Safari and Firefox will ignore the functionality with no ill effects but will not benefit from the speculative loading. Note that extensions may disable preloading by default (for example, uBlock Origin does this). - -Other browsers will not see any adverse effects, however the feature will not work for those clients. +The Speculation Rules API is a new web API, and the functionality used by the plugin is supported in Chromium-based browsers such as Chrome, Edge, or Opera using version 121 or above. Other browsers such as Safari and Firefox will ignore the functionality with no ill effects; they will simply not benefit from the speculative loading. Note that certain browser extensions may disable preloading by default. * [Browser support for the Speculation Rules API in general](https://caniuse.com/mdn-html_elements_script_type_speculationrules) -* [Information on document rules syntax support used by the plugin](https://developer.chrome.com/blog/chrome-121-beta#speculation_rules_api) +* [Information on document rules syntax support used by the plugin](https://developer.chrome.com/docs/web-platform/prerender-pages) _This plugin was formerly known as Speculation Rules._ @@ -48,12 +46,11 @@ _This plugin was formerly known as Speculation Rules._ = How can I prevent certain URLs from being prefetched and prerendered? = -Not every URL can be reasonably prerendered. Prerendering static content is typically reliable, however prerendering interactive content, such as a logout URL, can lead to issues. For this reason, certain WordPress core URLs such as `/wp-login.php` and `/wp-admin/*` are excluded from prefetching and prerendering. Additionally, any URL generated with `wp_nonce_url()` (or which contain the `_wpnonce` query var) is also ignored. You can exclude additional URL patterns by using the `plsr_speculation_rules_href_exclude_paths` filter. +Not every URL can be reasonably prerendered. Prerendering static content is typically reliable, however prerendering interactive content, such as a logout URL, can lead to issues. For this reason, certain WordPress core URLs such as `/wp-login.php` and `/wp-admin/*` are excluded from prefetching and prerendering. Additionally, any URL generated with `wp_nonce_url()` (or which contains the `_wpnonce` query var) is also ignored. You can exclude additional URL patterns by using the `plsr_speculation_rules_href_exclude_paths` filter. -This example would ensure that URLs like `https://example.com/cart/` or `https://example.com/cart/foo` would be excluded from prefetching and prerendering. +The following example ensures that URLs like `https://example.com/cart/` or `https://example.com/cart/foo` are excluded from prefetching and prerendering: ` Date: Mon, 11 Nov 2024 08:11:44 -0800 Subject: [PATCH 2/2] Include additional Speculative Loading readme updates. --- plugins/speculation-rules/readme.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/speculation-rules/readme.txt b/plugins/speculation-rules/readme.txt index 9de308792d..7802d57bfc 100644 --- a/plugins/speculation-rules/readme.txt +++ b/plugins/speculation-rules/readme.txt @@ -46,7 +46,7 @@ _This plugin was formerly known as Speculation Rules._ = How can I prevent certain URLs from being prefetched and prerendered? = -Not every URL can be reasonably prerendered. Prerendering static content is typically reliable, however prerendering interactive content, such as a logout URL, can lead to issues. For this reason, certain WordPress core URLs such as `/wp-login.php` and `/wp-admin/*` are excluded from prefetching and prerendering. Additionally, any URL generated with `wp_nonce_url()` (or which contains the `_wpnonce` query var) is also ignored. You can exclude additional URL patterns by using the `plsr_speculation_rules_href_exclude_paths` filter. +Not every URL can be reasonably prerendered. Prerendering static content is typically reliable, however prerendering interactive content, such as a logout URL, can lead to issues. For this reason, certain WordPress core URLs such as `/wp-login.php` and `/wp-admin/*` are excluded from prefetching and prerendering. Additionally, any URLs generated with `wp_nonce_url()` (or which contains the `_wpnonce` query var) and `nofollow` links are also ignored. You can exclude additional URL patterns by using the `plsr_speculation_rules_href_exclude_paths` filter. The following example ensures that URLs like `https://example.com/cart/` or `https://example.com/cart/foo` are excluded from prefetching and prerendering: ` @@ -88,9 +88,9 @@ Prerendering can affect analytics and personalization. For client-side JavaScript, is recommended to delay these until the prerender is activated (for example by clicking on the link). Some solutions (like Google Analytics) already do this automatically, see [Impact on Analytics](https://developer.chrome.com/docs/web-platform/prerender-pages#impact-on-analytics). Additionally, cross-origin iframes are not loaded until activation which can further avoid issues here. -Speculating with the default moderate eagerness increases the chance that the prerendered page will be visited by the user. In contrast, eager speculation increases the risk that prerendered pages will not be loaded. Alternatively, the plugin offers to only speculate on mouse/pointer down (conservative) which further reduces the risk and is an option for sites which are concerned about this, at the cost of having less of a lead time and so less of a performance gain. +Speculating with the default `moderate` eagerness decreases the risk that the prerendered page will not be visited by the user and therefore will avoid any side effects of loading such a link in advance. In contrast, `eager` speculation increases the risk that prerendered pages may not be loaded. Alternatively, the plugin offers to only speculate on mouse/pointer down (conservative) which reduces the risk even further and is an option for sites which are concerned about this, at the cost of having less of a lead time and so less of a performance gain. -A prerendered page is linked to the page that prerenders it, so personalisation may already be known by this point and changes (e.g. browsing other products, or logging in/out) may require a new page load, and hence a new prerender anyway, which will take these into account. But it definitely is something to be aware of and test! +A prerendered page is linked to the page that prerenders it, so personalisation may already be known by this point and changes (e.g. browsing other products, or logging in/out) often require a new page load, and hence a new prerender, which will then take these into account. But it definitely is something to be aware of and test! Prerendered pages can be canceled by removing the speculation rules `