Open notramo opened 1 year ago
I discovered that some APIs are not available at build time, e.g. window
.
So it can be detected with typeof window === 'undefined'
.
Please leave open this issue as a reminder to include this information somewhere in the tutorial (I might add it later when I get more familiar with Plenti).
Yeah window
is only available for CSR. During the build we create HTML fallbacks using SSR, so window
will not be available because there isn't a browser at that time. You can get around this by putting references to window
inside an onMount so it only loads clientside once the component is mounted and is ignored during SSR.
Is it possible to detect if the component is live, or being pre-rendered? This would be used to:
Some examples
Loading screen:
Placeholder instead of image, to speed up Svelte components loading: