-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on:load does not trigger on <script src=...> tags #8301
Comments
|
mstachowiak
added a commit
to gitcontext/svelte-turnstile
that referenced
this issue
Feb 2, 2024
Modifying script loading to accommodate the upcoming release of Svelte 5. The `on:load` event for scripts placed inside `<svelte:head>` does not fire in Svelte 5 as a result of this bug: sveltejs/svelte#8301 Instead of loading the Cloudfare Turnstile script in `<svelte:head>`, load the script dynamically during mount. This is functionally equivalent to using `<svelte:head>` but accommodates an operational load event handler. If Svelte 5 resolves Issue 8301, this is not needed.
This is something that also was not working in Svelte 4. Specifically, the script element has already loaded from SSR and when hydration occurs, the event listener gets added too late. |
This is working as expected, but there's a case to be made that we should fire synthetic load events during hydration. Closing this in favour of #11046 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
In order to add external scripts (such as https://apis.google.com/js/api.js), we need to trigger some execution once they are loaded, such as in this example:
The way to do it would be something such as below:
However it doesn't work and currently results in the following:
As you can see, onGapiloaded and onGISLoaded are not triggered.
Reproduction
npm create svelte@latest
.Current
package.json
looks like below:PS: Same issue with the following versions:
Logs
No response
System Info
System: OS: macOS 12.0.1 CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz Memory: 226.09 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.18.1 - /usr/local/bin/node Yarn: 1.22.11 - /usr/local/bin/yarn npm: 8.19.2 - /usr/local/bin/npm Browsers: Brave Browser: 71.0.58.21 Chrome: 110.0.5481.100 Firefox: 97.0.1 Safari: 15.1 npmPackages: svelte: ^3.54.0 => 3.55.1
Severity
annoyance
The text was updated successfully, but these errors were encountered: