Performance: Suspense for async components
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by managing how async components load and render.
<template>
<Suspense>
<template #default>
<AsyncComponent />
</template>
<template #fallback>
<div>Loading...</div>
</template>
</Suspense>
</template>
<script setup>
import AsyncComponent from './AsyncComponent.vue'
</script><template> <AsyncComponent /> </template> <script setup> import AsyncComponent from './AsyncComponent.vue' </script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Async component without Suspense | Minimal initial DOM | Single reflow after load | Large paint delay | [X] Bad |
| Async component with Suspense fallback | More DOM nodes for fallback | Single reflow for fallback + reflow for component | Smaller initial paint delay | [OK] Good |