Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tinkoff/browser-timings

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinkoff/browser-timings

Lightweighted browser timings metrics exporter

  • 0.12.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
865
increased by68.95%
Maintainers
0
Weekly downloads
 
Created
Source

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(() => {
    // setTimeout is necessary in order to get metrics about loadEventEnd
    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 timing from client to server */
  connection: number;
  /* How much time backend was preparing response */
  backend: number;
  /* Page download to client */
  pageDownload: number;
  /* Timing of first paint for a page */
  'first-paint': number;
  /* Timing when DOM becomes interactive */
  domInteractive: number;
  /* DOM building is complete */
  domComplete: number;
  /* Page and every resource were loaded */
  pageLoadTime: number;
  /* Common information about resources and its loading time grouped by type */
  download: {
    html: TimingResource;
    js: TimingResource;
    css: TimingResource;
    img: TimingResource;
    font: TimingResource;
    other: TimingResource;
  };
}

interface TimingResource {
  /* Timing of resource loading */
  duration: number;
  /* Byte-size measure of data used by resource */
  encodedDecodeSize: number;
  /* Byte-size measure of data transferred by network. Calculating difference between encodedDecodeSize - transferSize may reveal how much data where stored in browser cache */
  transferSize: number;
}

FAQs

Package last updated on 17 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc