Performance: Tailwind with Vue single-file components
MEDIUM IMPACT
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 |