Skip to content

Commit c735f52

Browse files
Update whole-geckos-think.md
1 parent 38b4877 commit c735f52

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

.changeset/whole-geckos-think.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,50 @@
22
'astro': major
33
---
44

5-
TODO:
5+
Updates `<script>` and `<style>` tags to render in the order they are defined
6+
7+
In Astro v5.5, the `experimental.preserveScriptOrder` flag was introduced to render multiple `<style>` and `<script>` tags in the same order as they were declared in the source code. Astro 5.x reversed their order in your generated HTML output. This could give unexpected results, for example, CSS styles being overridden by earlier defined style tags when your site was built.
8+
9+
Astro 6.0 removes this experimental flag and makes this the new default behavior in Astro: scripts and styles are now rendered in the order defined in your code.
10+
11+
#### What should I do?
12+
13+
If you were previously using this experimental feature, you must remove this experimental flag from your configuration as it no longer exists:
14+
15+
```diff
16+
// astro.config.mjs
17+
import { defineConfig } from 'astro/config';
18+
19+
export default defineConfig({
20+
experimental: {
21+
- preserveScriptOrder: true,
22+
},
23+
})
24+
```
25+
26+
Review your `<script>` and `<style>` tags to make sure they behave as desired. You may need to reverse their order:
27+
28+
```diff
29+
<!-- src/components/MyComponent.astro -->
30+
<p>I am a component</p>
31+
<style>
32+
body {
33+
- background: red;
34+
+ background: yellow;
35+
}
36+
</style>
37+
<style>
38+
body {
39+
- background: yellow;
40+
+ background: red;
41+
}
42+
</style>
43+
<script>
44+
- console.log("hello")
45+
+ console.log("world")
46+
</script>
47+
<script>
48+
- console.log("world!")
49+
+ console.log("hello!")
50+
</script>
51+
```

0 commit comments

Comments
 (0)