Performance: Progressive enhancement
MEDIUM IMPACT
Progressive enhancement improves initial page load speed and interaction readiness by delivering basic content first and layering advanced features later.
<script> let showWidget = false; let HeavyWidget; async function loadWidget() { const module = await import('./HeavyWidget.svelte'); HeavyWidget = module.default; showWidget = true; } </script> <button on:click={loadWidget}>Load Widget</button> {#if showWidget} <svelte:component this={HeavyWidget} /> {/if}
<script>import HeavyWidget from './HeavyWidget.svelte';</script> <HeavyWidget />
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Immediate full JS load | High (many nodes from full component) | Multiple reflows during load | High paint cost due to complex layout | [X] Bad |
| Basic HTML first + lazy JS | Low (simple DOM initially) | Single reflow when JS loads | Low paint cost initially | [OK] Good |