[wp-trac] [WordPress Trac] #42438: Add support for preload links (similar to resource hints)

WordPress Trac noreply at wordpress.org
Fri Jul 29 14:59:03 UTC 2022


#42438: Add support for preload links (similar to resource hints)
--------------------------------------+-------------------------
 Reporter:  nico23                    |       Owner:  swissspidy
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  6.1
Component:  Script Loader             |     Version:  4.9
 Severity:  normal                    |  Resolution:
 Keywords:  has-unit-tests has-patch  |     Focuses:
--------------------------------------+-------------------------

Comment (by adamsilverstein):

 [attachment:"42438.diff"] is an updated patch based on the original PR. I
 wasn't able to push to that [https://github.com/WordPress/wordpress-
 develop/pull/2505 PR] so I opened a [https://github.com/WordPress
 /wordpress-develop/pull/3041 new one] to run the tests.

 * Rename wp_preload_links() to wp_preload_resources()
 * Rename all variables with clearer naming
 * Remove reset of variable
 * Structural change: break into two loops - upper loop to gather unique
 resources, lower loop to output HTML for each unique resources

 I didn't touch `wp_resource_hints`, we can update that function and
 possibly consolidate logic into a helper on a follow up ticket; that
 shouldn't be a blocker to landing this enhancement.

 I also want to address some feedback from @swissspidy -

 > Are we confident the current API is intuitive enough and can be used to
 solve typical use cases? Having to use a filter to add a preload link vs.
 an imperative way (e.g. a wp_add_preload_link() function or so) is
 arguably not the best developer experience.

 I agree it would be good to build an imperative way to add these, however
 that can work alongside a filter like the one introduced here.

 Would you see a wp_add_preload_link function setting some sort of global
 we could then use as a starting value for the filter?

 > Already asked 4 years ago: what in WordPress core today would benefit
 from preload links? We should have some good use cases in core (or bundled
 themes) prior to adding this. There should be some examples that proof
 that the proposed API can solve these use cases.

 Great question! can we apply this in wp-admin and Gutenberg for example to
 help prioritize some loading and get a demonstrable performance gain?
 @mihai2u or @gziolo - any suggestions? It would be great to add some
 actual core usage of the new capability.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42438#comment:49>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list