Replies: 1 comment 3 replies
-
Hi @claus 👋 Good to hear from you again! I was actually pretty surprised myself by some of the changes in 5.0 around scripts and styles. The most unexpected part for me was that the new script processing finally triggered optimizations that had been around for a while but never kicked in. Especially the fact that scripts were being inlined when that had never happened before forced us to make some adjustments to our client router. From what I understand, you want to swap just the How are those stylesheets being created on your end? especially the ones that are not inside Adding Here are a few things you might try:
Long story short, I would really love to take a look at your actual project if that is possible. Would you be up for that? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not 100% sure if this is a problem with ReplacementSwap, Astro, or me.
Let me start with an example. Consider an Astro layout that looks roughly like this:
Here, instead of swapping the entire
<body>
we are using ReplacementSwap to only swap the<main>
element.<Header>
can't get detached from DOM because it has to maintain state.<body>
,<Header>
and other children of<body>
besides<main>
are left untouched during the swap.This works fine as long as script and style imports stay in the
<head>
. ClientRouter's (or ReplacementSwap's) swap algorithm properly merges the outgoing with the incoming<head>
contents. However, since Astro 5, script imports can be anywhere in the<body>
and style imports seem to appear in the<body>
as well.<body>
children other than<main>
do not get swapped, so if those elements happen to be new script and style imports.. those are never merged in, leading to missing styles and interactivity.So in practice i have a situation that looks like this:
Outgoing page, Route A:
Incoming page, Route B:
Only
<main>
is swapped (apart from<head>
contents). Script and style includes (Route B bundles) in the incoming page's<body>
are ignored, the resulting page will still have the Route A bundles.Is there a fix for that? Am i doing something wrong?
Beta Was this translation helpful? Give feedback.
All reactions