Proposal: Performance Budgets
Proposed directives
Document-Policy directives such as size-markup, size-images, size-styles, and size-scripts can specify (in kilobytes or kibibytes?) the cumulative sizes of a type of resource; a generic size directive can specify the limit to the size of a page, including all its assets.
Use-cases
-
User-agents can know the size limit of a page and its resources just from the response headers of the document. This can inform adaptations for metered connections. For example, the user-agent will know whether to proxy the full page through a webpage-compression service (e.g. Google Web Light), just the images, or none of it at all.
-
Authors will be able to specify generic size restrictions on third-party content they do not control. We already have ways for authors to specify image weight (the "max-bpp" directives), but this could generalize it to cumulative weights for resources by category.
-
Search engines will be able to more easily evaluate a page's relevance for users who send
prefers-reduced-datahints. -
Lazy and conditional loading makes it difficult to estimate the size of a page until the user has scrolled to the bottom. These directives can make ceilings on page-weight explicit.
Further discussion
-
How should setting a budget to "0" compare to blocking the resource in the CSP?
-
How should user-agents interpret budgets if the user-agent disables images, or disables images exceeding a certain size (common with content-blockers)?
-
What other performance budgets should we specify?
-
Is there any merit to including an "inf" value, effectively re-setting an existing size directive?
-
Should syntax take into account the possibility of future, non-performance types of budgets? If so, should this be split into another header (e.g. "Performance-Policy)? Examples may include a "privacy budget" (part of Google's Privacy Sandbox initiative) in which a UA and a website can specify a preferred budget and the UA can default to the minimum.