Performance: Column ordering
This affects the browser's layout and paint phases by changing the visual order of columns without altering the DOM structure.
<div class="row"> <div class="col order-2">First</div> <div class="col order-3">Second</div> <div class="col order-1">Third</div> </div>
<div class="row"> <div class="col">First</div> <div class="col">Second</div> <div class="col">Third</div> </div> <!-- To reorder, developer changes HTML order --> <div class="row"> <div class="col">Third</div> <div class="col">First</div> <div class="col">Second</div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Changing HTML order | Modifies DOM nodes order | Multiple reflows | High paint cost due to layout shifts | [X] Bad |
| Using Bootstrap order classes | No DOM changes | Single reflow | Lower paint cost, stable layout | [OK] Good |
.order-* class do in a grid layout?.order-* classes.order-* classes let you rearrange columns visually without changing their HTML order.order-first to place a column first, order-last to place last, and numeric order-* from 0 to 12 for custom order.class="col order-1" uses order-1 which is not guaranteed first. class="col order-first" uses order-first which explicitly places the column first. class="col order-0" uses order-0 which is valid but less clear than order-first. class="col order-last" places the column last.<div class="row"> <div class="col order-3">A</div> <div class="col order-1">B</div> <div class="col order-2">C</div> </div>
sm, md, lg to apply order changes at specific screen sizes.order-sm-first. order-first applies to all sizes. order-lg-first applies on large screens. order-last places last always.<div class="col order-2 order-md-1">First</div> <div class="col order-1 order-md-2">Second</div> <div class="col order-3">Third</div>
order-* without breakpoint applies. So orders are: First=2, Second=1, Third=3. Visual order: Second (1), First (2), Third (3).order-md-* overrides. First=1, Second=2, Third=3. Visual order: First, Second, Third.Pass the test and this pattern moves unknown