Navigation Timing is part of the Performance API and provides metrics associated with navigating from one page to another. For example, you can determine how much time it takes to load or unload a document, or log the time it took until DOM construction has finished and interaction with the DOM is possible.
Only the current document is included, so usually there is only one PerformanceNavigationTiming object to observe. It extends the PerformanceEntry interface with the entryType of "navigation" and also inherits from PerformanceResourceTiming, so all of the timestamps from the process of fetching the document are available as well.
The domContentLoadedEventEnd and domContentLoadedEventStart timestamps can be used to measure how long it takes process the DOMContentLoaded event handler.
This example uses a PerformanceObserver, which notifies the caller about new navigation performance entries as they are recorded in the browser's performance timeline. The example uses the buffered option to access entries that were recorded before the observer was created.