Performance API
The PerformanceSoftNavigation interface provides timing information about soft navigation as used by client-side routing on SPA sites. It is emitted when a browser observes a soft navigation to have taken place.
Instance properties
This interface directly defines the following properties:
- PerformanceSoftNavigation.interactionId
- : The id of the interaction that resulted in the soft navigation.
- PerformanceSoftNavigation.navigationType
- : The type of the navigation.
- PerformanceSoftNavigation.paintTime
- : Returns the DOMHighResTimeStamp of when the first rendering phase ended and the paint phase started.
- PerformanceSoftNavigation.presentationTime
- : Returns the DOMHighResTimeStamp of when the first painted pixels were actually drawn on the screen.
It also extends the following PerformanceEntry properties, qualifying and constraining them as described:
- PerformanceEntry.entryType
- : Returns
"soft-navigation".
- : Returns
- PerformanceEntry.duration
- : Returns the result of PerformanceSoftNavigation.presentationTime - PerformanceEntry.startTime.
- PerformanceEntry.name
- : The new URL navigated to.
- PerformanceEntry.startTime
- : Returns the DOMHighResTimeStamp of the interaction that resulted in the soft navigation.
Instance methods
- PerformanceSoftNavigation.getLargestInteractionContentfulPaint()
- : Returns the current largest InteractionContentfulPaint for this soft navigation.
- PerformanceSoftNavigation.toJSON()
- : Returns a JSON-serializable plain object representing the
PerformanceSoftNavigationobject. Automatically called by JSON.stringify().
- : Returns a JSON-serializable plain object representing the
Description
The PerformanceSoftNavigation interface is driven by the browser observing the following:
- A trusted user interaction.
- A visible, Contentful Paint as a result of that interaction updating the screen.
- A URL update in the user's address bar as a result of that interaction.
Having the browser provide this rather than a routing framework calling an API to emit this entry allows SPA performance timing to be measured consistently regardless of how different applications handle navigations (for example, updating the URL at the start or the end of navigation processing).
The PerformanceSoftNavigation interface allows developers to measure SPA performance metrics such as:
- First Contentful Paint: Can be measured as the first paint from the soft navigation time.
- Largest Contentful Paint: Can be measured via the InteractionContentfulPaint for the soft navigation.
- CLS: Can be calculated between navigations.
- Interaction to Next Paint: Can be calculated between navigations.
Examples
Observing soft navigations
In the following example, a PerformanceObserver is used to log the soft navigations. The buffered flag is used to access data from before observer creation.
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
console.log("Soft Nav:", entry.startTime, entry.name);
}
});
observer.observe({ type: "soft-navigation", buffered: true });
Specifications
Browser compatibility
See also
- Measuring soft navigations on developer.chrome.com (2026)
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
