You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
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).
In the <Nav> component I have added the following:
<svelte:head><script>console.log('hello from Nav');</script><scriptsrc='some-script.js'></script>{@html'<script src="some-other-script.js"></script>'}</svelte:head>
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:
hello from Nav
hello from some-script.js
hello from some-other-script.js
hello from Nav
hello from some-script.js
Expected behavior
I would expect the following to be logged:
hello from Nav
hello from some-script.js
hello from some-other-script.js
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
begonaalvarezd, DylanVann, anthonygraignic, thebrianbug, Clipi-12 and 1 more