@@ -23,32 +23,35 @@ function sendWebVitals() {
2323 // LoAFs that intersect with the event.
2424 return entry . startTime < ( loaf . startTime + loaf . duration ) && loaf . startTime < ( entry . startTime + entry . duration ) ;
2525 } ) . forEach ( loaf => {
26+ const loafEndTime = loaf . startTime + loaf . duration ;
2627 loaf . scripts . forEach ( script => {
27- const totalDuration = script . startTime + script . duration ;
28- if ( totalDuration > loafAttribution . debug_loaf_script_total_duration ) {
29- loafAttribution = {
30- // Stats for the LoAF entry itself.
31- debug_loaf_entry_start_time : loaf . startTime ,
32- debug_loaf_entry_end_time : loaf . startTime + loaf . duration ,
33- debug_loaf_entry_work_duration : loaf . renderStart ? loaf . renderStart - loaf . startTime : loaf . duration ,
34- debug_loaf_entry_render_duration : loaf . renderStart ? loaf . startTime + loaf . duration - loaf . renderStart : 0 ,
35- debug_loaf_entry_total_forced_style_and_layout_duration : loaf . scripts . reduce ( ( sum , script ) => sum + script . forcedStyleAndLayoutDuration , 0 ) ,
36- debug_loaf_entry_pre_layout_duration : loaf . styleAndLayoutStart ? loaf . styleAndLayoutStart - loaf . renderStart : 0 ,
37- debug_loaf_entry_style_and_layout_duration : loaf . styleAndLayoutStart ? loaf . startTime + loaf . duration - loaf . styleAndLayoutStart : 0 ,
38-
39- // Stats for the longest script in the LoAF entry.
40- debug_loaf_script_total_duration : totalDuration ,
41- debug_loaf_script_compile_duration : script . executionStart - script . startTime ,
42- debug_loaf_script_exec_duration : script . startTime + script . duration - script . executionStart ,
43- debug_loaf_script_invoker : script . invoker ,
44- debug_loaf_script_type : script . invokerType ,
45- debug_loaf_script_source_url : script . sourceURL ,
46- debug_loaf_script_source_function_name : script . sourceFunctionName ,
47- debug_loaf_script_source_char_position : script . sourceCharPosition ,
48-
49- // LoAF metadata.
50- debug_loaf_meta_length : longAnimationFrames . length ,
51- }
28+ if ( script . duration <= loafAttribution . debug_loaf_script_total_duration ) {
29+ return ;
30+ }
31+ loafAttribution = {
32+ // Stats for the LoAF entry itself.
33+ debug_loaf_entry_start_time : loaf . startTime ,
34+ debug_loaf_entry_end_time : loafEndTime ,
35+ debug_loaf_entry_work_duration : loaf . renderStart ? loaf . renderStart - loaf . startTime : loaf . duration ,
36+ debug_loaf_entry_render_duration : loaf . renderStart ? loafEndTime - loaf . renderStart : 0 ,
37+ debug_loaf_entry_total_forced_style_and_layout_duration : loaf . scripts . reduce ( ( sum , script ) => sum + script . forcedStyleAndLayoutDuration , 0 ) ,
38+ debug_loaf_entry_pre_layout_duration : loaf . styleAndLayoutStart ? loaf . styleAndLayoutStart - loaf . renderStart : 0 ,
39+ debug_loaf_entry_style_and_layout_duration : loaf . styleAndLayoutStart ? loafEndTime - loaf . styleAndLayoutStart : 0 ,
40+
41+ // Stats for the longest script in the LoAF entry.
42+ debug_loaf_script_total_duration : script . duration ,
43+ debug_loaf_script_compile_duration : script . executionStart - script . startTime ,
44+ debug_loaf_script_exec_duration : script . startTime + script . duration - script . executionStart ,
45+ debug_loaf_script_source : script . sourceLocation || script . invoker || script . name , // TODO: remove after Chrome 123
46+ debug_loaf_script_type : script . invokerType || script . type , // TODO: remove `|| script.type` after Chrome 123
47+ // New in Chrome 122/123 (will be null until then)
48+ debug_loaf_script_invoker : script . invoker ,
49+ debug_loaf_script_source_url : script . sourceURL ,
50+ debug_loaf_script_source_function_name : script . sourceFunctionName ,
51+ debug_loaf_script_source_char_position : script . sourceCharPosition ,
52+
53+ // LoAF metadata.
54+ debug_loaf_meta_length : longAnimationFrames . length ,
5255 }
5356 } ) ;
5457 } ) ;
0 commit comments