There is React application with one route. I make several API requests to get data from backend. While fetching I show loading spinner and actual data after successful requests. I need to get time in milliseconds how much time did it take to get all files (like js files and so on), make requests and display data. How can I do that? I see there is Performance API but it seems to be deprecated.
I tried to use Performance API but it’s deprecated.
2
Answers
Absolutely! You can indeed use the getTime function to get the timestamp before and after making the API call to calculate the API response time.
Using
console.time
andconsole.timeEnd
:Using PerformanceObserver
Create a new
PerformanceObserver
instance with the ‘navigation
‘ entry typeUsing Third-Party Libraries
Libraries like
react-performance-wrapper
orreact-perf
can provide more detailed performance insights and profiling capabilities within your React components