One listener instead of 200 took INP from 290ms to 110ms
INP — Interaction to Next Paint — measures click responsiveness. A hidden cost: attaching a separate click-listener to hundreds of items. Each one uses memory and slows the page's reaction. Think of it like giving every guest their own doorbell instead of one for the house.
A table with 200 rows attached a click handler to every row, so clicks lagged and INP sat at 290ms.
The fix was 'event delegation' — one listener on the parent that figures out which row was clicked:
— Removed 200 individual listeners.
— Added 1 listener on the table container.
— It reads which row fired the click and acts on it.
Result: INP dropped to 110ms, and the page used less memory too.
Try this: if you attach listeners in a loop, one parent listener often does the same job faster.
Vitals 101
@CoreVitals101
One listener instead of 200 took INP from 290ms to 110ms
Этот пост опубликован в Telegram-канале Vitals 101. Подписаться можно по ссылке: @CoreVitals101.