mdn/content

Topic on setting HTTP priority of resource requests

Open

#14 803 ouverte le 8 avr. 2022

Voir sur GitHub
 (3 commentaires) (0 réactions) (0 assignés)Markdown (22 427 forks)batch import
Content:Performancedocument not writtenhelp wanted

Métriques du dépôt

Stars
 (8 900 stars)
Métriques de merge PR
 (Merge moyen 7j 3h) (147 PRs mergées en 30 j)

Description

When loading a page with many resources it can be useful to prioritize the requests so that the page appears to render more quickly. It would be useful to have a topic on this.

There are a bunch of ways to do this:

  • Use fetch() and set the priority in Request.priority.
  • Set the HTTP priority on HTMLLinkElement, HTMLIFrameElement, and HTMLImageElement elements (and associated tags) using the fetchpriority attribute.
  • In future maybe Priority HTTP header. There are also some ideas (from here), some of which may be relevant (e.g. marking the non-critical ones as async):
  • Mark non-critical scripts as async
  • Consider inlining @font-face declarations directly into HTML
  • Avoid using CSS background images or @import
  • Use preload to retrieve critical resources earlier

Possible locations for such a page are under these:

This comes out of the discussion here: https://github.com/mdn/content/issues/14561

Guide contributeur