⏱️
SEO & marketing

INP: Optimising JavaScript for Faster Page Responsiveness

02.12.2026
← All articles

INP (Interaction to Next Paint) measures the time from a user action, such as a tap, a menu click or a keystroke in a search box, until the next frame shows a visible change. Since March 2024 it has replaced FID in Core Web Vitals. FID only measured the delay of the first interaction; INP considers interactions across the whole visit and reports a value close to one of the slowest. Google rates up to 200 ms as good and over 500 ms as poor.

What INP is made of

Each interaction has three parts: input delay, when the main thread is busy and cannot start your handler; processing time, when your click or input handlers run; and presentation delay, when the browser recalculates layout and paints. The common enemy is long tasks, meaning any JavaScript run longer than 50 ms, during which the browser cannot respond or repaint. The core idea is simple: never hold the main thread for long.

Finding the slow interaction

PageSpeed Insights and Search Console show field INP but not which element is to blame. Record in the Chrome DevTools Performance panel with CPU throttling enabled, perform the suspect action and look for long tasks. For real-user detail, the open-source web-vitals library reports the element and the slow phase:

<script type="module">
import { onINP } from 'https://unpkg.com/web-vitals@4?module';
onINP((metric) => {
  console.log('INP:', metric.value, metric.attribution);
}, { reportAllChanges: true });
</script>

Break up long tasks

Split big jobs into chunks and yield to the browser between them. Rendering 500 catalogue cards in one loop can take hundreds of milliseconds; yielding every 50 cards lets the browser handle input in between. Newer Chrome versions offer scheduler.yield(), with setTimeout as a fallback.

function yieldToMain() {
  if (globalThis.scheduler?.yield) {
    return scheduler.yield();
  }
  return new Promise((resolve) => setTimeout(resolve, 0));
}

async function renderProducts(items) {
  for (let i = 0; i < items.length; i++) {
    renderItem(items[i]);
    if (i % 50 === 0) {
      await yieldToMain();
    }
  }
}

Respond first, work later

Show visual feedback immediately, yield, then do the heavy work. Otherwise users think the page froze and click again. Defer non-urgent work such as analytics events the same way.

filterButton.addEventListener('click', async () => {
  filterButton.classList.add('is-loading');   // instant visual feedback
  await yieldToMain();                          // let the browser paint
  applyFilters();                               // heavy work afterwards
  filterButton.classList.remove('is-loading');
});

Debounce input and avoid layout thrashing

Filtering a whole list on every keystroke multiplies the cost; debounce waits for a short pause and runs once. Interleaving size reads and style writes forces repeated layout calculations, so read everything first, then write. Very large DOMs make every update more expensive.

function debounce(fn, ms) {
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => fn(...args), ms);
  };
}

searchInput.addEventListener('input', debounce(filterList, 200));
// Bad: reads and writes interleaved in every iteration
cards.forEach((card) => {
  const h = card.offsetHeight;      // read (forces layout)
  card.style.height = h + 10 + 'px'; // write
});

// Good: read everything first, then write
const heights = cards.map((card) => card.offsetHeight);
cards.forEach((card, i) => {
  card.style.height = heights[i] + 10 + 'px';
});

Move heavy computation to a Web Worker

Loan schedules, large JSON processing or in-browser image compression can run in a Web Worker on a separate thread, keeping the page responsive. Workers cannot touch the DOM; they post results back to the main thread.

Example: a furniture store filter

A Tashkent furniture store on misol.uz re-sorted 800 products and redrew the whole list on every filter click, while three analytics scripts fired events. Field INP was above 500 ms. Adding an instant loading state, rendering in batches of 50, debouncing the price field and deferring analytics cut interaction time several-fold in DevTools, and field data reached "good" within weeks. Review third-party widgets, ads and maps too, and load the necessary ones with defer or after the first interaction. Fast hosting such as sayt.uz delivers pages sooner, but INP lives in browser JavaScript and must be fixed in code.

Related articles

🔎 Telegram Posts in Google: Do They Get Indexed and Do They Help SEO? 📞 The Contact Page: Address, Phone and Company Details That Build Trust 🧭 Do lots of 404 pages hurt SEO? When you should actually worry 🧩 Google Tag Manager basics: tags, triggers and variables
🌐 Language
🇺🇿 O⁠'zbek 🇺🇿 Özbek (yangi) 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓