Performance: How Tailwind differs from Bootstrap
This affects page load speed and rendering performance by changing how CSS is loaded and applied.
Jump into concepts and practice - no test required
<!-- Tailwind CSS with PurgeCSS to remove unused styles --> <link href="tailwind.min.css" rel="stylesheet"> <div class="container mx-auto p-4"> <button class="bg-blue-600 text-white px-4 py-2 rounded">Click me</button> </div>
<!-- Bootstrap CSS loaded fully --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <div class="container"> <button class="btn btn-primary">Click me</button> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Bootstrap full CSS | Normal DOM | 1 reflow after CSS load | High paint cost due to large CSS | [X] Bad |
| Tailwind with PurgeCSS | Normal DOM | 1 reflow after CSS load | Low paint cost due to small CSS | [OK] Good |
Tailwind and Bootstrap?p-4 matches Tailwind's padding class for 1rem.<div class="bg-blue-500 hover:bg-blue-700 text-white p-4">Button</div>
bg-blue-500 sets a medium blue background; hover:bg-blue-700 changes background to a darker blue on hover.text-white makes text white; p-4 adds padding. So background is blue, text white, changes on hover.<button class="btn btn-primary p-4">Click</button>
p-4, but btn and btn-primary are Bootstrap classes, not Tailwind.p-4 is valid padding in Tailwind; button tags can have classes; classes are space-separated.btn or btn-primary classes by default -> Option Bshadow-lg adds a large shadow, rounded-lg adds rounded corners, p-6 adds padding, and bg-white sets background color.card which is not Tailwind; "btn btn-primary p-6 rounded" uses Bootstrap classes; "container box p-6 shadow-md" uses container and box which are not for card styling.