Skip to content

Bug: Auto generated preload links should respect fetchpriority if specified #26810

Closed
@liuyenwei

Description

@liuyenwei

React version: 18.3.0-canary-a389046a5-20230512

Steps To Reproduce

  1. Server render a React component that renders either <script> or <link> tags with fetchpriority set
  2. Observe that React will add <link rel="preload"> links for each of the discovered resources but without the same fetchpriority set.

Link to code example:

The current behavior

Currently, if we server render a component such as the one below:

<html lang="en">
  <head>
    <link rel="stylesheet" href="/styles.css" fetchpriority="low" ></link>
  </head>
  <body>
    <script src="/script.js" fetchpriority="low" ></script>
  </body>
</html>

React will also render preload links for the script and link but without the fetchpriority set:

<head>
    <link rel="preload" as="style" href="/styles.css" />
    <link rel="preload" as="script" href="/script.js" />
    <link rel="stylesheet" href="/styles.css" fetchpriority="low" ></link>
  </head>
  <body>
    <script src="/script.js" fetchpriority="low"></script>
  </body>

The result is that both styles.css and script.js are fetched with fetchpriority set to high

The expected behavior

When generating preload links for script and link components, React should respect fetchpriority if specified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions