File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
packages/javascript/src/addons Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ interface LoAFEntry extends PerformanceEntry {
6363 } [ ] ;
6464}
6565
66+ /**
67+ * Check whether the browser supports a given PerformanceObserver entry type
68+ *
69+ * @param type - entry type name, e.g. `'longtask'` or `'long-animation-frame'`
70+ */
6671function supportsEntryType ( type : string ) : boolean {
6772 try {
6873 return (
@@ -75,6 +80,11 @@ function supportsEntryType(type: string): boolean {
7580 }
7681}
7782
83+ /**
84+ * Subscribe to Long Tasks (>50 ms) via PerformanceObserver
85+ *
86+ * @param onEntry - callback fired for each detected long task
87+ */
7888function observeLongTasks ( onEntry : ( e : LongTaskEvent ) => void ) : void {
7989 if ( ! supportsEntryType ( 'longtask' ) ) {
8090 log ( 'Long Tasks API is not supported in this browser' , 'info' ) ;
@@ -100,6 +110,12 @@ function observeLongTasks(onEntry: (e: LongTaskEvent) => void): void {
100110 } catch { /* unsupported — ignore */ }
101111}
102112
113+ /**
114+ * Subscribe to Long Animation Frames (>50 ms) via PerformanceObserver.
115+ * Provides script-level attribution (Chrome 123+, Edge 123+).
116+ *
117+ * @param onEntry - callback fired for each detected LoAF entry
118+ */
103119function observeLoAF ( onEntry : ( e : LongTaskEvent ) => void ) : void {
104120 if ( ! supportsEntryType ( 'long-animation-frame' ) ) {
105121 log ( 'Long Animation Frames (LoAF) API is not supported in this browser' , 'info' ) ;
You can’t perform that action at this time.
0 commit comments