UMD Web Utilities Library
    Preparing search index...

    Function observeLCP

    • Create a PerformanceObserver for largest contentful paint (LCP)

      Observes Largest Contentful Paint using the Performance API. Note: LCP can fire multiple times as larger elements are rendered.

      Parameters

      Returns () => void

      Cleanup function to disconnect observer

      const cleanup = observeLCP((entry) => {
      console.log('LCP:', entry.value, 'ms');
      console.log('Rating:', entry.rating);
      });

      // Later, to stop observing:
      cleanup();