For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/lynx-api/performance-api/performance-observer/observe.md.
Lynx
  • English
  • PerformanceObserver: observe() method

    Specifies types of performance events to observe and starts observing. The callback function set when creating the PerformanceObserver will be invoked when a matching PerformanceEntry is received.

    Syntax

    observe(entryIdentifiers: string[]): void

    Parameters

    entryIdentifiers

    entryIdentifiers: string[];

    A string list of identifiers for the PerformanceEntry to be observed.

    You can use entryType or entryType.name as identifiers. For example, you can use "metric" to listen to performance events for the entire metric type, including MetricFcpEntry and MetricActualFmpEntry. Alternatively, you can use "metric.fcp" to listen only to the MetricFcpEntry performance event.

    Refer to PerformanceEntry.entryType and PerformanceEntry.name for available types and names. Unrecognized types will be ignored. If no valid types are found, observe() will not function.

    Tip

    It is recommended to call this method during initialization, such as in the constructor of a root component or within the useMemo Hook, to ensure it is called as early as possible when the component or page loads, to avoid missing any data.

    Return Value

    None (undefined)

    Examples

    Observing all performance events under certain entryTypes

    This example creates a PerformanceObserver that observes the entire PerformanceEntry of types through ["metric", "pipeline"].

    Observing specific performance events

    This example creates a PerformanceObserver that observes MetricFcpEntry and the entire PerformanceEntry of type pipeline through ["metric.fcp", "pipeline"].

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.