Skip to content

Injecting CSS via <svelte:head> breaks loading +layout css #13086

Closed
@brianschwabauer

Description

@brianschwabauer

Describe the bug

One of my pages has the following code. Adding this code prevents the proper CSS loading for all subsequent +layout/+page css files. The /+layout.svelte?t=1724986125513&svelte&type=style&lang.css file shows up in the network tab, but the css is never injected into the head of the document.

<svelte:head>
  <link rel="stylesheet" href="https://example.com/styles.css" />
  <script type="module" src="https://example.com/script.esm.js"></script>
</svelte:head>

Here's a video showing me navigating from the "Delivery Page" page (where the svelte:head code is) to the "Media" page where the CSS is broken. But when I refresh on the "Media " page, the CSS loads properly.
https://github.com/user-attachments/assets/5c52acd0-8738-4092-b97b-d15b7e2a59f2

Reproduction

Here's a minimal reproduction:

https://stackblitz.com/edit/svelte5-sveltehead-css-issue?file=src%2Froutes%2F%2Blayout.svelte,src%2Froutes%2Fchild1%2F%2Bpage.svelte,src%2Froutes%2Fchild2%2F%2Bpage.svelte,src%2Froutes%2Fchild3%2F%2Bpage.svelte

Here's the real world video of it happening:

2024-08-30.15-59-57.mp4

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Memory: 28.03 GB / 63.86 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.5.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.2.0 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Chrome: 127.0.6533.100
    Edge: Spartan (44.19041.1266.0), Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    svelte: 5.0.0-next.240 => 5.0.0-next.240

Severity

blocking an upgrade

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