diff --git a/src/service/performance-impl.js b/src/service/performance-impl.js index 534741bac9e4..0f09d96c2b4f 100644 --- a/src/service/performance-impl.js +++ b/src/service/performance-impl.js @@ -19,6 +19,7 @@ import {VisibilityState} from '#core/constants/visibility-state'; import {Signals} from '#core/data-structures/signals'; import {whenDocumentComplete, whenDocumentReady} from '#core/document-ready'; import {layoutRectLtwh} from '#core/dom/layout/rect'; +import {computedStyle} from '#core/dom/style'; import {throttle} from '#core/types/function'; import {dict, map} from '#core/types/object'; @@ -203,6 +204,11 @@ export class Performance { whenDocumentComplete(win.document).then(() => this.onload_()); this.registerPerformanceObserver_(); this.registerFirstInputDelayPolyfillListener_(); + + /** + * @private {boolean} + */ + this.googleFontExpRecorded_ = false; } /** @@ -466,6 +472,20 @@ export class Performance { */ tickCumulativeMetrics_() { if (this.supportsLayoutShift_) { + if (!this.googleFontExpRecorded_) { + this.googleFontExpRecorded_ = true; + const {win} = this; + const googleFontExp = parseInt( + computedStyle(win, win.document.body).getPropertyValue( + '--google-font-exp' + ), + 10 + ); + if (googleFontExp >= 0) { + this.addEnabledExperiment(`google-font-exp=${googleFontExp}`); + } + } + this.tickLayoutShiftScore_(); } if (this.supportsLargestContentfulPaint_) {