Skip to content

Commit a3b5695

Browse files
authoredJan 11, 2024
Don't try to load partytown scripts in the main thread during view transitions (#9658)
1 parent e72efd6 commit a3b5695

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
 

‎.changeset/early-taxis-love.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro": patch
3+
---
4+
5+
Fixes an issue caused by trying to load text/partytown scripts during view transitions

‎packages/astro/src/transitions/router.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ function runScripts() {
151151
let wait = Promise.resolve();
152152
for (const script of Array.from(document.scripts)) {
153153
if (script.dataset.astroExec === '') continue;
154+
const type = script.getAttribute('type');
155+
if (type && type !== 'module' && type !== 'text/javascript') continue;
154156
const newScript = document.createElement('script');
155157
newScript.innerHTML = script.innerHTML;
156158
for (const attr of script.attributes) {
157159
if (attr.name === 'src') {
158160
const p = new Promise((r) => {
159-
newScript.onload = r;
161+
newScript.onload = newScript.onerror = r;
160162
});
161163
wait = wait.then(() => p as any);
162164
}

0 commit comments

Comments
 (0)
Please sign in to comment.