Skip to content

[LinkTagModuleImport] render blocking #1375

Open

Description

@trusktr

Some people want to solve FOUC with module <link> stylesheet tags.

I didn't see it in the explainer, so I thought I'd comment that I think it should be non-blocking by default, with opt in:

Non-blocking:

<link
  rel=stylesheet
  type=module
  href=foo
/>

Blocking (one way to avoid FUOC with the trade off that content after the link tag is not rendered until after the network request):

<link
  rel=stylesheet
  type=module
  href=foo
  blocking
/>

Activity

  1. trusktr commented on Aug 8, 2026

    @trusktr
    Author
  2. KurtCattiSchmidt commented on Aug 8, 2026

    @KurtCattiSchmidt
    Contributor

    Joe Pea (@trusktr) - per the current spec'd behavior of <link rel=stylesheet>, blocking is already supported on <link rel=stylesheet>, which this proposal would inherit: https://html.spec.whatwg.org/#attr-link-blocking.

  3. trusktr commented on Aug 8, 2026

    @trusktr
    Author

    Based on other threads, I think people are desiring for it to work anywhere, not only in the <head> like classic link stylesheet tags. This means there would need to be either a change to class non-module <link> stylesheet tag behavior, or it would need to be behavior difference only for link stylesheet tags with type="module".

    <head>
      <!-- blocking on classic stylesheet links works in <head> only. -->
      <link rel="stylesheet" href="foo.css" blocking="render" />
    </head>
    
    <body>
      <!-- with module stylesheet links, render blocking works anywhere: -->
      <link rel="stylesheet" href="module.css" blocking="render" />
    
      <div>
        <!-- this doesn't get rendered until the sheet is loaded -->
        <template shadowrootmode="open">
          <link rel="stylesheet" type="module" href="other.css" blocking="render" />
    
          shadow content
        </template>
      </div>
    </body>

    This would make it useful for solving FOUC in a simple way, for example in streaming scenarios where enumerating the whole page content up front in the server is not desired, for example AI response streams where we can't wait for all content to be enumerated before sending it to the client.

    I made a PR mentioning the difference: #1376

    There's some detail not mentioned about how to actually handle it. For example the parser still needs to remove <template> right after parsed, but rendering (including shadow root creation, or at least the creation of the shadow content) won't happen until after the stylesheet is fetched and ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions