Performance: Text wrapping and overflow
MEDIUM IMPACT
This affects how text content is displayed and how the browser handles layout and repaint when text overflows or wraps.
<div class="container" style="width: 200px;"> <p class="text-break">ThisIsAReallyLongWordThatDoesNotWrapAndCausesOverflow</p> </div>
<div class="container" style="width: 200px;"> <p>ThisIsAReallyLongWordThatDoesNotWrapAndCausesOverflow</p> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Long unbroken text without wrapping | Minimal | Multiple on resize | High due to overflow repaint | [X] Bad |
| Using text-break to wrap long words | Minimal | Single initial | Low paint cost | [OK] Good |
| No wrapping with overflow visible | Minimal | Multiple on resize | High paint and scroll cost | [X] Bad |
| Using text-truncate to clip overflow | Minimal | Single initial | Low paint cost | [OK] Good |