What is the way to run external js function in client side in SvelteKit. #9917
Replies: 3 comments
-
did you figure this out? I am having the exact same problem at the moment |
Beta Was this translation helpful? Give feedback.
-
I mean using <script src="/assets/js/vendor/jquery.min.js"></script>
<script src="/assets/js/script.js"></script>
<script>
setUpAppBehavior();
</script> That should execute regardless of the development or production environment. If you do need to wait for the layout or component code in Svelte to have been executed, you can use
I see you are trying to tell typescript that the setUpAppBehavior is coming from the outside with |
Beta Was this translation helpful? Give feedback.
-
import { onMount } from 'svelte';
onMount(() => {
alert('hello');
}); Note that depending on how your |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an external js file which declare a function setUpAppBehavior. The function is responsible for some cool animation in my website
First I included the js file in my app.html
And then in my +layout.svelte file I did this
I tried also with this snippet
let isServer = import.meta.env.SSR;
but same result as in the browser case...What am I missing ? What this the right way to do this ? Run the js function in client side.
Beta Was this translation helpful? Give feedback.
All reactions