File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7171 }
7272 </ script >
7373
74- < script src =/js/obs.speedcurve.js?v =0012 type=module> </ script >
74+ < script src =/js/obs.speedcurve.js?v =0013 type=module> </ script >
Original file line number Diff line number Diff line change 4040 // Keep source identifiers descriptive while limiting their beacon cost.
4141 const CUSTOM_DATA_KEYS = {
4242 cpuTier : 'cpu' ,
43+ lcpContentType : 'lcpt' ,
4344 fromCache : 'fc' ,
4445 contentEncoding : 'ce' ,
4546 responseStatus : 'rs' ,
6667 }
6768 }
6869
70+ // Record whether the latest Largest Contentful Paint candidate has a URL.
71+ if (
72+ typeof PerformanceObserver === 'function' &&
73+ Array . isArray ( PerformanceObserver . supportedEntryTypes ) &&
74+ PerformanceObserver . supportedEntryTypes . indexOf (
75+ 'largest-contentful-paint'
76+ ) !== - 1
77+ ) {
78+ new PerformanceObserver ( ( list ) => {
79+ const entries = list . getEntries ( ) ;
80+ const entry = entries [ entries . length - 1 ] ;
81+ if ( entry ) {
82+ lux . addData (
83+ CUSTOM_DATA_KEYS . lcpContentType ,
84+ entry . url ? 'image' : 'text'
85+ ) ;
86+ }
87+ } ) . observe ( { type : 'largest-contentful-paint' , buffered : true } ) ;
88+ }
89+
6990 const navigation = performance . getEntriesByType ( 'navigation' ) [ 0 ] ;
7091
7192 if ( ! navigation ) return ;
You can’t perform that action at this time.
0 commit comments