Performance: Tailwind with Vue single-file components
This affects page load speed by adding CSS size and rendering speed by how styles are applied in Vue components.
<template> <div class="p-4 bg-blue-500 text-white rounded-lg shadow-lg"> <p class="text-lg font-bold">Hello World</p> </div> </template> <script setup> // Use Tailwind JIT with purge configured to remove unused classes </script>
<template> <div class="p-4 bg-blue-500 text-white rounded-lg shadow-lg"> <p class="text-lg font-bold">Hello World</p> </div> </template> <style> /* No Tailwind optimization, all classes used everywhere */ </style>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using full Tailwind CSS without purge in Vue SFC | Normal DOM nodes | 1 reflow per layout change | High paint cost due to large CSS | [X] Bad |
| Using Tailwind JIT with purge in Vue SFC | Normal DOM nodes | 1 reflow per layout change | Low paint cost with small CSS | [OK] Good |
<template>
<div class="flex justify-center items-center h-64 bg-gray-100">
<button class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded">Submit</button>
</div>
</template><template>
<div class="flex justify-center items-center bg-gray-100">
<button class="bg-blue-500 text-white p-2 rounded">Click</button>
</div>
</template>Pass the test and this pattern moves unknown