-
|
In Svelte 4, the compiler hoisted pure functions even if they were not declared in
Demo / Svelte 4.0.0 (example from Svelte 4 documentation)
But in Svelte 5, this is no longer the case, and I can't find any mention of this change anywhere. Demo / Svelte 5.46.0 (example from Svelte 4 documentation)
Demo / Svelte 5.46.0 as
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Svelte 5 did have a lot more hoisting, but that was removed because it did not yield any significant benefits at the cost of making everything more complicated. Would recommend measuring whether your example makes a difference in your specific case and only optimize if there is a reason to. E.g. depending on the number of instances it might be irrelevant anyway. |
Beta Was this translation helpful? Give feedback.
-
|
Got it, thanks. |
Beta Was this translation helpful? Give feedback.



Svelte 5 did have a lot more hoisting, but that was removed because it did not yield any significant benefits at the cost of making everything more complicated.
Would recommend measuring whether your example makes a difference in your specific case and only optimize if there is a reason to. E.g. depending on the number of instances it might be irrelevant anyway.