Performance: Text transform utilities
Text transform utilities affect the rendering speed by changing how text is displayed without altering the DOM structure.
<p class="text-uppercase">hello world</p>
HTML: <p id="text">hello world</p> JavaScript: document.getElementById('text').textContent = document.getElementById('text').textContent.toUpperCase();
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| JavaScript text content change | Modifies DOM text node | 1 reflow per change | 1 repaint | [X] Bad |
| CSS text-transform utility | No DOM changes | 0 reflows | Paint only if style changes | [OK] Good |
text-uppercase changes all letters to uppercase, text-lowercase to lowercase, and text-capitalize capitalizes the first letter of each word.text-uppercase is the correct class.text-lowercase exactly as the class name for lowercase transformation.class='text-lowercase' inside the paragraph tag.<p class='text-capitalize'>hello world from bootstrap</p>
text-capitalize class changes the first letter of each word to uppercase.<div class='text-lower'>Sample Text</div>
text-lowercase, not text-lower.div, so the tag is not the issue.text-capitalize capitalizes the first letter of each word, not just the first letter of the entire text.Pass the test and this pattern moves unknown