Performance: Dismissible alerts
This affects page interaction responsiveness and visual stability when users close alert messages.
<div class="alert alert-warning alert-dismissible fade show" role="alert">Warning!<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>
<div class="alert alert-warning" role="alert">Warning!<button onclick="this.parentElement.style.display='none'">Close</button></div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline style hide on click | 1 element style change | 1 reflow per dismissal | 1 repaint | [X] Bad |
| Bootstrap dismissible alert with fade | Element removed after fade | 1 reflow with transition | 1 repaint with transition | [OK] Good |
dismissible alert in Bootstrap?alert-dismissible combined with alert.<div class="alert alert-warning alert-dismissible fade show" role="alert"> Warning! Check your input. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div>
alert-dismissible, fade, and show classes with a close button having data-bs-dismiss="alert".<div class="alert alert-success alert-dismissible" role="alert"> Success! Your form was submitted. <button type="button" class="btn-close" aria-label="Close"></button> </div>
data-bs-dismiss="alert" to trigger alert dismissal.btn-close and data-bs-dismiss="alert".Pass the test and this pattern moves unknown