Wydajność

perf/yield-long-tasks

Main-thread work over 50 ms is split and yields, and event handlers do the visible update first (INP 200 ms or less).

umiarkowanaręcznefe-core-web-vitals

Dlaczego

While a long task runs, the page cannot paint the result of a click or key press. INP measures that delay for the slowest interactions; "good" is 200 ms or less at the 75th percentile. Big re-renders, JSON parsing, analytics and validation inside a handler are the usual causes.

Poprawka

In a handler, update the UI first, then yield and do the rest (saving, analytics, recalculation). Split loops over large data into chunks and yield between them with scheduler.yield() where it exists and a setTimeout fallback. Move pure computation to a Web Worker. Measure with the DevTools Performance panel and the web-vitals attribution build.

Przykłady

const yieldToMain = () => (globalThis.scheduler?.yield ? scheduler.yield() : new Promise((r) => setTimeout(r, 0)))
button.addEventListener('click', async () => {
  showSpinner()          // visible update first
  await yieldToMain()
  await saveAndTrack()   // the rest after the next paint
})

Źródła

Fakty

Identyfikator
perf/yield-long-tasks
Waga
umiarkowana
Sprawdzanie
ręczne ocenia człowiek; raport podaje to jako listę kontrolną
Dotyczy plików
jsx vue svelte astro html
Uczy jej skill
fe-core-web-vitals Core Web Vitals
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain perf/yield-long-tasks