Bug 247291 - Add support for Fetch Priority
Summary: Add support for Fetch Priority
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Enhancement
Assignee: Nobody
URL:
Keywords: InRadar
Depends on: 254028 252739 255008
Blocks:
  Show dependency treegraph
 
Reported: 2022-10-31 14:58 PDT by Patrick Meenan
Modified: 2023-08-23 23:12 PDT (History)
21 users (show)

See Also:


Attachments
Patch (48.39 KB, patch)
2023-02-14 03:15 PST, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Meenan 2022-10-31 14:58:56 PDT
The Priority Hints spec is in the process of being merged into the fetch and HTML specs and allows for site developers to hint at the relative fetch priority for various resources.

The main changes are:
* Adds a "priority" to fetch's Request and RequestInit classes that uses a string enum of "auto", "high" or "low"
* Adds a "fetchPriority" attribute to the IMG, PICTURE, SCRIPT, LINK and IFRAME html elements with the same enum values

Existing spec: https://wicg.github.io/priority-hints/

This was shipped in Chromium 103 and Mozilla is working on an implementation so it is now in the process of being moved into the HTML and fetch specs.

The main use case developers are currently using it for is to tag "important" images on their pages so that they load sooner than the would naturally.  Chrome usage from the field can be seen here: https://chromestatus.com/metrics/feature/timeline/popularity/2738
Comment 1 Radar WebKit Bug Importer 2022-11-07 13:59:16 PST
<rdar://problem/102058327>
Comment 2 Rob Buis 2023-02-14 03:15:32 PST
Created attachment 464982 [details]
Patch
Comment 3 Rob Buis 2023-02-14 05:20:40 PST
Pull request: https://github.com/WebKit/WebKit/pull/10084
Comment 4 Patrick Meenan 2023-02-16 13:40:18 PST
FYI, there is discussion on the HTML spec PR about removing it from iFrame and leaving it as a hint for same-document subresources and exploring iFrame scheduling separately.

https://github.com/whatwg/html/pull/8470#discussion_r1106835444

I imagine that WebKit has a lot of similar details to Chrome for why prioritizing the fetch of the iFrame navigation resource might be ineffective and not do what the site devs are trying to achieve (prioritizing across frame boundaries at the document and network level probably won't do anything in Chrome for example).

Script, IMG and Link tag fetchpriority attributes (as well as fetch RequestInit) all still have very clear use cases though.
Comment 5 Rob Buis 2023-02-16 13:46:12 PST
(In reply to Patrick Meenan from comment #4)
> FYI, there is discussion on the HTML spec PR about removing it from iFrame
> and leaving it as a hint for same-document subresources and exploring iFrame
> scheduling separately.
> 
> https://github.com/whatwg/html/pull/8470#discussion_r1106835444
> 
> I imagine that WebKit has a lot of similar details to Chrome for why
> prioritizing the fetch of the iFrame navigation resource might be
> ineffective and not do what the site devs are trying to achieve
> (prioritizing across frame boundaries at the document and network level
> probably won't do anything in Chrome for example).
> 
> Script, IMG and Link tag fetchpriority attributes (as well as fetch
> RequestInit) all still have very clear use cases though.

Thanks for the link! As it happens I did not start on making iframe + priority hints work because, I guess like others found out, it would be a lot more changes/plumbing to make that work. I would be fine too of course removing the idl for it.
Comment 6 EWS 2023-02-22 01:37:24 PST
Committed 260666@main (adf13d454519): <https://commits.webkit.org/260666@main>

Reviewed commits have been landed. Closing PR #10084 and removing active labels.
Comment 7 Rob Buis 2023-02-22 03:42:43 PST
Still needs implementation.
Comment 8 Chris Dumez 2023-02-23 08:25:09 PST
Comment on attachment 464982 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=464982&action=review

> Source/WebCore/Modules/fetch/RequestPriority.idl:28
> +  "high"

Someone pointed out on Slack that this is missing commas between the values, please follow-up and fix.
Comment 9 Rob Buis 2023-04-19 02:48:42 PDT
I implemented the feature, but don't have the expertise to work on bug 254028, so I am removing myself as assignee.
Comment 10 Barry Pollard 2023-04-19 04:23:58 PDT
FYI, in Chrome we're trying to consolidate on "Fetch Priority" and avoid using "Priority Hints" going forward to reduce developer confusion.

More info:
- https://twitter.com/tunetheweb/status/1648399924424237058?s=20
- https://web.dev/fetch-priority/#history
Comment 11 Anne van Kesteren 2023-08-23 23:12:34 PDT
Closing this as fixed as per bug 255008. We'll continue to track the inspector work in bug 254028.