catchpoint / WebPageTest.RUM-SpeedIndex

Calculate SpeedIndex measurements from the field
MIT License
199 stars 37 forks source link

Deprecated chrome.loadTimes() even on recent Chrome versions (not always) #19

Open GuillaumeRossolini opened 5 years ago

GuillaumeRossolini commented 5 years ago

Hi

This looks like a repeat of #16 and I wasn't sure at first because the warning doesn't trigger for every page we collect statistics thanks to this lib. However, I have now seen the warning in my browser. I am not sure what triggered this.

[Edit] Actually, I have a reproduce case:

It may be an event triggered on page unload

Romiko commented 3 years ago

Hi,

Any news on this one? [Deprecation] chrome.loadTimes() is deprecated, instead use standardized API: Paint Timing

`

  (anonymous) @ rum-speedindex.js:1
  RUMSpeedIndex @ rum-speedindex.js:1
  (anonymous) @ (index):25

` The solution for this is: https://developers.google.com/web/updates/2017/12/chrome-loadtimes-deprecated

function startLoadTime() { // If the browser supports the Navigation Timing 2 and HR Time APIs, use // them, otherwise fall back to the Navigation Timing 1 API. if (window.PerformanceNavigationTiming && performance.timeOrigin) { const ntEntry = performance.getEntriesByType('navigation')[0]; return (ntEntry.startTime + performance.timeOrigin) / 1000; } else { return performance.timing.navigationStart / 1000; } }

and function requestTime() { // If the browser supports the Navigation Timing 2 and HR Time APIs, use // them, otherwise fall back to the Navigation Timing 1 API. if (window.PerformanceNavigationTiming && performance.timeOrigin) { const ntEntry = performance.getEntriesByType('navigation')[0]; return (ntEntry.startTime + performance.timeOrigin) / 1000; } else { return performance.timing.navigationStart / 1000; } }

Is this possible to update. Would you like me to create a PR for this?