Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performace API - not supported in Safari Browser

I am planning to track page load time in Javascript with the help of Performance Navigation API. But , It is not supported in safari. Here is the code:

*var performance = window.performance;
var timet = performance.getEntriesByType("navigation")[0].duration;*

Receiving an error "Performance" is undefined. It seems Performace API is deprecated. Is there any alternate way to capture page load time using Javascript?

like image 296
TestUser Avatar asked Oct 16 '25 13:10

TestUser


1 Answers

The problem is that performance.getEntriesByType("navigation") returns an empty array in Safari (still the case as of Safari 14...)

Relevant bug: https://bugs.webkit.org/show_bug.cgi?id=184363

Note that you can use the old version of the API exposed as performance.timing https://developer.mozilla.org/en-US/docs/Web/API/Performance/timing It doesn't have all the same data and some data might have different format though.

like image 72
jakub.g Avatar answered Oct 19 '25 08:10

jakub.g



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!