Skip to main content
InterviewHubPRO
Section Overview
Q37

Question 37 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

74%
Web Vitals & Performance (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Long Animation Frames API (LoAF): Debugging Main Thread Freezes.

senior LevelCode ExampleSystem DesignHTTP & REST APIs

In Simple Words: The Long Animation Frames API (LoAF) is the browser-native successor to the Long Tasks API. It reports frames that took longer than $50\text{ms}$ to render and provides exact attribution:

  • Reports the specific script URL, function name, and character position that caused the lag.
  • Identifies whether the delay was caused by layout recalculation, style mutations, or excessive JavaScript execution.
javascript
// Observing Long Animation Frames using PerformanceObserver
const observer = new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    console.warn(`Long Frame (${entry.duration.toFixed(1)}ms):`, {
      blockingDuration: entry.blockingDuration,
      scripts: entry.scripts.map(s => ({
        source: s.sourceURL,
        invoker: s.invoker,
        duration: s.duration
      }))
    });
  }
});

observer.observe({ type: 'long-animation-frame', buffered: true });