web-vitals icon indicating copy to clipboard operation
web-vitals copied to clipboard

onTTFB woes with iOS

Open cwli24 opened this issue 2 years ago • 1 comments

Howdy, I'm having trouble with getting onTTFB to work with automated iOS tests. Just a cursory look into getNavigationEntry() suggests it gets polyfilled, but I'm still running into trouble.

let waitForTTFB;
if (typeof PerformanceNavigationTiming !== 'undefined') {
  waitForTTFB = new Promise(resolve => {
    onTTFB(({ value, entries }) => {
      // do some calculations with nav entry

      resolve() // data is ready?
    })
  })
// ^ this _should_ work for iOS >= 15.2 completely... but I find that my promise doesn't get resolved.
// I test this same block against Chrome, Edge, FF, macOS Safari 16, Android (against multiple recent versions of each), and
// they all work fine.
} else if (typeof PerformanceTiming !== 'undefined') {
 // Had to do this since iOS < v15.2 doesn't support PerformanceNavigationTiming and wouldn't work with onTTFB in tests
}

cwli24 avatar Mar 18 '23 03:03 cwli24

I have the same issue, TTFB won't fire on first page load when I inject the script using the IAB. It will fire after the second page load.

ap-shahar avatar May 09 '23 06:05 ap-shahar

Closing this as we not planned as v4 dropped the Navigation Timing polyfill since only a small number of browsers need it.

tunetheweb avatar Apr 15 '25 19:04 tunetheweb