-
-
Notifications
You must be signed in to change notification settings - Fork 432
<script>'s in <svelte:head> are running twice (unless wrapped in {@html}) #1124
Comments
Hi, I have tried to replicate this problem, but I didn't manage to do so. |
Updating |
Hi @jervtub, I've just tried with a fresh clone of my sample repo and updated both Svelte and Sapper to the latest versions ("sapper": "^0.27.13", "svelte": "^3.22.3") and the issue remains. |
I have checked out your repo, the problem indeed occurs, my problem. |
Got the same issue, and jquery load twice. @jervtub could you help let us know if the issue has been resolved? |
Unfortunately, I haven't had time to continue with bug resolving due writing my thesis. To resolve this, this might be more complex than I initially expected (I am still new to the code base of Sapper and Svelte). Maybe the core development team can take a closer look. Furthermore, today I have found a decent amount of the time to attempt tackling it once again. |
I expect this would be fixed by sveltejs/svelte#4309. You could test to see if using https://github.com/wix-incubator/wix-svelte fixes this for you, which is a fork by that author containing the patch |
Hi @benmccann confirmed the issue has been resolved with your version. Thanks alot.
|
Hi @benmccann sorry, After tried several times, The issue still happening. |
I have the same issue, firebase + stripe are loaded twice when added in svelte:head (even in only one place) |
Can you see if this still happens if you upgrade to 0.28.0 and set Head hydration was improved and I wonder if that would make a difference here. If that doesn't work, it'd be interesting to test if the svelte hydration fix mentioned above #1124 (comment) now works with these improvements applied |
That fixed the issue for me. Can this setting have side effects?
|
For reference @benmccann I've linked a issue reproduction repo in sveltejs/svelte#4982 which seems to be the upstream issue
|
Was pulling my hair out over this. It would be great to fix or document it if we don't want to pull resources from SvelteKit :) |
Add hydratable to prevent head duplication when scripts run in <svelte:head> Sapper PR with solve: sveltejs/sapper#1124 (comment)
Describe the bug
Adding a
<script>
tag to<svelte:head>
causes the script to be run twice. I believe this is down to Sapper generating the SSR code and then later on hydrating the page with the same element. However, wrapping the script in a@html
directive only runs the script once (it looks like the hydration isn't duplicating the element).Logs
N/A
To Reproduce
I have created a small repo (using sapper-template) that reproduces the issue: https://github.com/notscottthompson/sapper-head-script-test
In the
<Nav>
component I have added the following:some-script.js
logs "hello from some-script.js".some-other-script.js
logs "hello from some-other-script.js".The following is logged in the browser when loading the test page:
Expected behavior
I would expect the following to be logged:
Stacktraces
N/A
Information about your Sapper Installation:
Your browser and the version: Chrome 80.0
Your operating system: Ubuntu Linux 18.04
Your hosting environment: Local
Sapper version: 0.27.10
Svelte version: 3.20.1
If it is an exported (npm run export) or dynamic application: dynamic (
npm run dev
)Whether your application uses Webpack or Rollup: Rollup
Severity
Only mildly annoying. However, due to not being an expert in Svelte/Sapper I'm worried that this may be something I shouldn't be doing (wrapping scripts in
@html
) or that there may be a better way to achieve it.Additional context
N/A
The text was updated successfully, but these errors were encountered: