Browser-timings
Lib for measure client browsers performance. Automatically collects performance data on page load.
Installation
Install npm package
npm i --save @tinkoff/browser-timings
How to
import { browserTimings } from '@tinkoff/browser-timings';
window.addEventListener('load', () => {
setTimeout(() => {
const perfData = browserTimings();
}, 0);
});
After executing perfData
will contain client performance metrics which may be send to any external system for further analysis.
Call of the library should be executed only after page load in order to get actual data. Otherwise, it may return empty object without data.
Lib interface
export interface Timings {
connection: number;
backend: number;
pageDownload: number;
'first-paint': number;
domInteractive: number;
domComplete: number;
pageLoadTime: number;
download: {
html: TimingResource;
js: TimingResource;
css: TimingResource;
img: TimingResource;
font: TimingResource;
other: TimingResource;
};
}
interface TimingResource {
duration: number;
encodedDecodeSize: number;
transferSize: number;
}