--- title: Frame Timing API slug: Web/API/Frame_Timing_API tags: - Guide - NeedsTranslation - Overview - TopicStub - Web Performance translation_of: Web/API/Frame_Timing_API ---
The PerformanceFrameTiming
interface provides frame timing data about the browser's event loop. A frame represents the amount of work a browser does in one event loop iteration such as processing DOM events, resizing, scrolling, rendering, CSS animations, etc. A frame rate of 60 fps (frames per second) for a 60 Hz refresh rate is a common target for a good responsive user experience. This means the browser should process a frame in about 16.7 ms.
An application can register a {{domxref("PerformanceObserver")}} for "frame
" {{domxref("PerformanceEntry","performance entry types")}}. The observer (callback) will be notified when new "frame
" events are added to the browser's performance timeline and the frame's {{domxref("PerformanceEntry.duration","duration")}} (length of time) will be available. This data can be used to help identify areas that take too long to provide a good user experience.
Example code of the interfaces described in this document is included in Using the Frame Timing API.
frames
The {{domxref("PerformanceFrameTiming")}} interface extends the following {{domxref("PerformanceEntry")}} properties (for "frame
" {{domxref("PerformanceEntry.entryType","performance entry types")}}) by qualifying and constrainting the properties as follows:
frame
".startTime
s of two successive frames.This data, particularly the duration
timestamp, can be used to help identify performance problems.
{{experimental_inline}}The performance observer interfaces allow an application to register an observer for specific {{domxref("PerformanceEntry","performance event types")}}. When one of those event types is recorded in the browser's performance timeline, the application is notified of the event via the observer's callback function that was specified when the observer was created.
To observe "frame
" performance entry types, the application first creates a {{domxref("PerformanceObserver")}} object with a specific frame observer callback (function). Next, {{domxref("PerformanceObserver.observe()")}} is used to specify the set of performance events to observe - in this case, just the "frame
" event type. When the browser adds a new frame to the performance timeline, the specified observer callback will be invoked.
When a frame {{domxref("PerformanceObserver","observer")}} is invoked, frame {{domxref("PerformanceEntry","performance entries")}} can be retrieved by calling {{domxref("PerformanceObserverEntryList.getEntriesByType()")}} with an argument of "frame
". This method returns a list of "frame
" {{domxref("PerformanceEntry")}} objects. Each frame object's {{domxref("PerformanceEntry.duration","duration")}} property returns the timestamp of two consecutive frames. If this value is greater than the time needed to provide a good user experience, further analysis might be warranted.
{{experimental_inline}}As shown in the {{domxref("PerformanceFrameTiming")}} interface's Browser Compatibility table, this interface has no implementations.