WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 8 weeks ago

#42438 assigned defect (bug)

preload is missing from ressource hints.

Reported by: nico23 Owned by: swissspidy
Milestone: 5.0 Priority: normal
Severity: normal Version: 4.9
Component: Script Loader Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

<link rel="preload" ...

is currently not possible, while others like prefetch are.

Attachments (1)

add_preload_to_ressource_hints.patch (716 bytes) - added by nico23 7 months ago.
patch

Download all attachments as: .zip

Change History (4)

#1 @swissspidy
2 months ago

  • Keywords has-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 5.0
  • Owner set to swissspidy
  • Status changed from new to assigned

Previously: #34292, #38121

Browser support looks much better now: https://caniuse.com/#feat=link-rel-preload

#2 @swissspidy
2 months ago

  • Component changed from General to Script Loader

#3 @igrigorik
8 weeks ago

Hey folks! Would love to see preload available in core. A couple of drive-by thoughts..

Resource Hints [1] and Preload [2] have different semantics; Resource Hints != Preload.

  • dns-prefect, preconnect, prefetch, prerender are speculative optimization hints
  • preload is a directive to the UA to fetch the resource

Addy Osmani has a nice writeup on the differences [3]. My recommendation would be to keep Preload and RH as separate APIs, because they have different processing behavior and attributes. Case in point, current wp_resource_hints() exposes "as" attribute, but that only applies to rel=preload resources. On a related note "pr" attribute is now deprecated, so that can be removed from the function as well.

Concretely, I'd propose...

  1. Do some cleanup on wp_resource_hints() to remove "pr" and "as".
  2. Expose new wp_preload() function to emit preload links.

WDYT? Crazytalk? :)

--- [1] https://w3c.github.io/resource-hints/ [2] https://w3c.github.io/preload/ [3] https://medium.com/reloading/preload-prefetch-and-priorities-in-chrome-776165961bbf

Note: See TracTickets for help on using tickets.