Performance: Form input patterns
MEDIUM IMPACT
Form input patterns affect page interactivity and input responsiveness, impacting how quickly users can interact with forms without delays.
<input type="text" class="border p-2" oninput="debouncedValidate(event)" /> <script>const debouncedValidate = debounce((e) => { /* lightweight validation */ }, 300); function debounce(fn, delay) { let timer; return (...args) => { clearTimeout(timer); timer = setTimeout(() => fn(...args), delay); }; }</script>
<input type="text" class="border p-2" oninput="validateInput(event)" onkeyup="validateInput(event)" /> <script>function validateInput(e) { /* heavy validation logic */ }</script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy input event handlers on every keystroke | 1 per keystroke | Multiple reflows per input | High paint cost due to blocking | [X] Bad |
| Debounced input validation | 1 per debounce interval | Single reflow per validation | Low paint cost | [OK] Good |
| Fixed width input styling | 1 on resize | Reflow triggered on viewport change | Medium paint cost | [!] Bad |
| Responsive width with Tailwind classes | Minimal DOM ops | No reflows on resize | Low paint cost | [OK] Good |
| SVG icon with pointer-events and aria-hidden | Minimal DOM ops | No extra reflows | Low paint cost | [OK] Good |