Skip to content

Only the first import of an async chunk waits for the CSS #23652

Closed

Description

@kiwixz

Describe the bug

My SvelteKit website loads pages asynchronously, but I can see a flash of unstyled content when navigating to some pages. It seems that it tries to preload the page, do some stuff and then import the chunk again. But the second import does not wait for the CSS?

Found this random PR on a random fork which seems to try fixing the same bug: marko-js/vite#320.

AI says this:

The preload helper marks a dependency as seen when it inserts the <link>, not when the link has loaded, and returns early for seen dependencies (if (dep.href in seen) return). Only the call that inserted the link awaits its load event.

Reproduction

https://drop-5a75d175-5d4.kiwixz.workers.dev/

repro.zip

Steps to reproduce

F5 the page multiple time, you will see second import resolving before CSS is loaded.

System Info

Binaries:
    Node: 24.21.0
    npm: 9.2.0
  npmPackages:
    vite: ^8.3.2 => 8.3.2

Used Package Manager

npm

Logs

No response

Validations

Activity

  1. added theissue type on Oct 5, 2026
  2. added a commit that references this issue on Oct 8, 2026
    036b745
  3. added a commit that references this issue on Oct 12, 2026
  4. locked and limited conversation to collaborators on Oct 23, 2026
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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions