web-vitals
web-vitals copied to clipboard
onTTFB woes with iOS
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
}
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.
Closing this as we not planned as v4 dropped the Navigation Timing polyfill since only a small number of browsers need it.