partey_workadventure/front/src/Components/Lazy.svelte

22 lines
350 B
Svelte
Raw Normal View History

2022-03-08 11:56:34 +01:00
<!-- https://lihautan.com/notes/svelte-lazy-load/ -->
<script>
export let when = false;
export let component;
let loading;
$: if (when) {
load();
}
function load() {
loading = component();
}
</script>
{#if when}
{#await loading then { default: Component }}
<Component />
{/await}
{/if}