[wp-trac] [WordPress Trac] #62503: Add speculative loading support

WordPress Trac noreply at wordpress.org
Thu Nov 21 18:39:10 UTC 2024


#62503: Add speculative loading support
-----------------------------+------------------------------------------
 Reporter:  flixos90         |      Owner:  flixos90
     Type:  feature request  |     Status:  assigned
 Priority:  normal           |  Milestone:  6.8
Component:  General          |    Version:
 Severity:  normal           |   Keywords:  needs-patch needs-unit-tests
  Focuses:  performance      |
-----------------------------+------------------------------------------
 With the [https://wordpress.org/plugins/speculation-rules/ Speculative
 Loading plugin] being successfully used on over 40,000 WordPress sites
 today, this ticket is about introducing the feature in WordPress Core.

 As outlined in the [https://make.wordpress.org/core/2024/04/09
 /speculative-loading-in-wordpress/ speculative loading announcement post],
 speculative loading using the Speculation Rules API “can lead to near-
 instant page load times”. As such, it is a crucial feature in improving
 load time performance and (in terms of performance metrics) LCP. Please
 refer to the post for additional context on what the feature does and how
 it works. Feel free to review the [https://developer.chrome.com/docs/web-
 platform/prerender-pages Chrome documentation about the Speculation Rules
 API] as well.

 There are several signals that indicate that the feature is ready for
 WordPress Core:
 * The [https://wordpress.org/plugins/speculation-rules/ Speculative
 Loading plugin] has amassed 40,000+ active installs and has been used for
 over 6 months without major issues, while receiving exclusively 5-star
 ratings.
 * Based on data queried from [https://httparchive.org/ HTTP Archive] and
 [https://developer.chrome.com/docs/crux CrUX] datasets over all 6+ months
 since the plugin launched, the sites that enabled speculative loading
 improved their LCP passing rate by ~1.9% at the median which, while it may
 seem a small number, is a huge boost for one specific feature, considering
 that 100s of sites with various performance implications contribute to the
 data.
 * Based on
 [https://chromestatus.com/metrics/feature/timeline/popularity/3932 Chrome
 stats on Speculation Rules API usage], speculative loading is already used
 on over 8% of Chrome page loads.
 * [https://blog.cloudflare.com/introducing-speed-brain/ Cloudflare has
 enabled speculative loading at large scale], providing assurance that even
 at a large scale like WordPress Core’s the feature would function without
 issues and lead to great results. In the linked post, they share data that
 their enabling of the feature led to a “reduction in LCP of 45% on
 successful prefetches”.
 * Based on data from a joint experiment between Chrome and Shopify,
 conservative prefetch on Shopify sites gave a 50-60 ms P75 LCP improvement
 for successful prefetches depending on the platform (for an overall 30-50
 ms P75 LCP improvement across the entire origins).

 The proposed approach for implementing speculative loading in WordPress
 Core is to port over most of the code from the
 [https://wordpress.org/plugins/speculation-rules/ Speculative Loading
 plugin], with some key differences:
 * There should not be any options or UI controls to customize the behavior
 of the feature. Instead a filter should be introduced for that purpose.
 * The default behavior should “prefetch” URLs instead of “prerender” them,
 and the eagerness should be “conservative” instead of “moderate”.
 Basically we would be starting with the safest possible default, which
 should still give reasonable performance wins per the data above.
     * The plugin would continue to use the more performant yet riskier
 configuration of “prerender” with “moderate” eagerness, to further assess
 the implications of that configuration in the long term.
     * Once speculative loading would be merged into Core, the plugin would
 be modified to rely on Core’s implementation, but alter the default Core
 configuration as outlined.
 * Rather than explicitly defining “prefetch” and “conservative” as the
 default values for the filter, a custom value “auto” should be used for
 the default, with the value signifying that WordPress Core makes the
 decision on how to speculatively load URLs. This will allow us to refine
 the default behavior for those sites in the future to achieve even bigger
 performance wins, e.g. if support of certain speculative loading behaviors
 across WordPress plugins and/or the web as a whole improves or additional
 research data suggests a better default.

 The differences were informed by the plugin usage as well as the
 aforementioned Cloudflare’s large-scale enabling of speculative loading.
 They have rolled out conservative prefetching for now, but
 [https://blog.cloudflare.com/introducing-speed-
 brain/#:~:text=Looking%20ahead%2C%20we%20plan%20to%20explore%20more%20dynamic%20eagerness%20settings%20for%20sites%20that%20could%20benefit%20from%20a%20more%20liberal%20setting%2C%20and%20we%27ll%20also%20expand%20our%20rules%20to%20include%20prerendering.
 anticipate being able to iterate on it in the future].

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62503>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list