MCPcopy
hub / github.com/ampproject/amphtml / processEntry

Method processEntry

src/service/performance-impl.js:409–458  ·  view source on GitHub ↗
(entry)

Source from the content-addressed store, hash-verified

407 let recordedFirstInputDelay = false;
408 let recordedNavigation = false;
409 const processEntry = (entry) => {
410 if (entry.name == 'first-paint' && !recordedFirstPaint) {
411 this.tickDelta(
412 TickLabel_Enum.FIRST_PAINT,
413 entry.startTime + entry.duration
414 );
415 recordedFirstPaint = true;
416 } else if (
417 entry.name == 'first-contentful-paint' &&
418 !recordedFirstContentfulPaint
419 ) {
420 const value = entry.startTime + entry.duration;
421 this.tickDelta(TickLabel_Enum.FIRST_CONTENTFUL_PAINT, value);
422 this.tickSinceVisible(
423 TickLabel_Enum.FIRST_CONTENTFUL_PAINT_VISIBLE,
424 value
425 );
426 recordedFirstContentfulPaint = true;
427 } else if (
428 entry.entryType === 'first-input' &&
429 !recordedFirstInputDelay
430 ) {
431 const value = entry.processingStart - entry.startTime;
432 this.tickDelta(TickLabel_Enum.FIRST_INPUT_DELAY, value);
433 recordedFirstInputDelay = true;
434 } else if (entry.entryType === 'layout-shift') {
435 // Ignore layout shift that occurs within 500ms of user input, as it is
436 // likely in response to the user's action.
437 if (!entry.hadRecentInput) {
438 this.tickLayoutShiftScore_(entry);
439 this.layoutShiftSum_ += entry.value;
440 }
441 } else if (entry.entryType === 'largest-contentful-paint') {
442 this.tickLargestContentfulPaint_(entry);
443 } else if (entry.entryType == 'navigation' && !recordedNavigation) {
444 [
445 'domComplete',
446 'domContentLoadedEventEnd',
447 'domContentLoadedEventStart',
448 'domInteractive',
449 'loadEventEnd',
450 'loadEventStart',
451 'requestStart',
452 'responseStart',
453 ].forEach((label) => this.tick(label, entry[label]));
454 recordedNavigation = true;
455 } else if (entry.entryType == 'event' && entry.interactionId) {
456 this.tickInteractionToNextPaint_(entry.duration);
457 }
458 };
459
460 const entryTypesToObserve = [];
461 if (this.win.PerformancePaintTiming) {

Callers

nothing calls this directly

Calls 7

tickDeltaMethod · 0.95
tickSinceVisibleMethod · 0.95
tickLayoutShiftScore_Method · 0.95
tickMethod · 0.95
forEachMethod · 0.45

Tested by

no test coverage detected