Performance: Button groups
MEDIUM IMPACT
Button groups affect the rendering speed and interaction responsiveness of grouped buttons on a page.
<div class="btn-group" role="group" aria-label="Basic example"> <button type="button" class="btn btn-primary">One</button> <button type="button" class="btn btn-primary">Two</button> <button type="button" class="btn btn-primary">Three</button> <button type="button" class="btn btn-primary">Four</button> <button type="button" class="btn btn-primary">Five</button> </div>
<div class="btn-group"> <button type="button" class="btn btn-primary">One</button> <button type="button" class="btn btn-primary">Two</button> <button type="button" class="btn btn-primary">Three</button> </div> <div class="btn-group"> <button type="button" class="btn btn-primary">Four</button> <button type="button" class="btn btn-primary">Five</button> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple separate btn-groups | High (many nodes) | Multiple reflows per group | High paint cost | [X] Bad |
| Single btn-group with all buttons | Low (fewer nodes) | Single reflow | Lower paint cost | [OK] Good |