-
I have a component that could appear hundreds or thousands of times in a page, and he has his own nested components
And do you know if in Svelte and Sveltekit both behaviors are the same ? Thanks ! |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Mar 3, 2024
Replies: 1 comment 6 replies
-
Unless you do some weird things (like manually inlining the code and serving that for each instance), both should only be loaded once. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is the same with SvelteKit.
In Svelte 4, state is stored as local variables inside a function, if you look at the generated code for a simple component with a counter you will find this:
Each component creates a new instance of the component class (here
App
) which has its own internal state, created via theinstance
function.(In Svelte 5 components themselves are functions rather …