# window-performance-statistics

> Package for getting usable values from window.performance

Latest version **1.2.5** (published 2017-11-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install window-performance-statistics
pnpm add window-performance-statistics
yarn add window-performance-statistics
bun add window-performance-statistics
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.5 |
| Published | 2017-11-04 |
| First published | 2017-09-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | dj10dj100 |
| Maintainers | dj10dj100 |
| Keywords | window, performance, js, window.performance, metrics, object, performanceData |

## Links

- npm: https://www.npmjs.com/package/window-performance-statistics
- Repository: https://github.com/dj10dj100/window-performance-statistics
- Homepage: https://github.com/dj10dj100/window-performance-statistics#readme
- Issues: https://github.com/dj10dj100/window-performance-statistics/issues
- npm.io page: https://npm.io/package/window-performance-statistics

## Dependencies (3)

- [add-react](https://npm.io/package/add-react.md) ^1.0.3
- [precommit-hook](https://npm.io/package/precommit-hook.md) ^3.0.0
- [babel-preset-es2015](https://npm.io/package/babel-preset-es2015.md) ^6.24.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.5 (latest) — 2017-11-04
- 1.2.4 — 2017-10-29
- 1.2.3 — 2017-10-07
- 1.2.2 — 2017-10-07
- 1.2.0 — 2017-10-07
- 1.0.3 — 2017-09-15
- 1.0.2 — 2017-09-15
- 1.0.1 — 2017-09-15
- 1.0.0 — 2017-09-15

## README

[![npm](https://img.shields.io/npm/dm/window-performance-statistics.svg)]()
[![npm](https://img.shields.io/npm/dt/window-performance-statistics.svg)]()
[![npm](https://img.shields.io/npm/v/window-performance-statistics.svg)]()

### <a href="https://www.npmjs.com/package/window-performance-statistics">Window Performance Statistics </a>

Small javascript package that converts the information found  in window.performance api to usable metrics, useful for tracking page timing events. 

You may not need this package, but it's code that I've found myself reusing in several places - so thought I'd package it into something useful for others.

Package is designed for a `es2015+` environment so will need transpiling before use in older browsers.

Add this to your project by using `yarn add window-performance-statistics` or `npm install window-performance-statistics`;

```javascript
import { getTiming } from 'window-performance-statistics';
```


Can only call this method once the browser has finished loading from inside a 
```javascript
window.onload = function () { 
    const timings = getTiming();
};
//OR for jQuery friends
$(document).ready(() =>{
    const timings = getTiming();
});

``` 


# Methods
## <a name="getTiming()">getTiming()</a>

**Parameters**

**{`time`} string | null**
```javascript 
getTiming('seconds')
```
Pass in seconds for all results to be returned in human readable seconds. Default is null, milliseconds.

**Returns -> Timing Response**

**Timing Response Properties**

| Name | Type | Description |
| --- | --- | --- |
| pageComplete | <code>number</code> | {`time`} Page load time, from initial request => complete |
| responseTime | <code>number</code> | {`time`} Server response time |
| domComplete | <code>number</code> | {`time`} Time from response to domComplete firing |
| dns | <code>number</code> | {`time`} DNS lookup timing |
| ttfb | <code>number</code> | {`time`} Time to first byte |
| tti | <code>number</code> | {`time`} Time took for DOM to be interactive |


Example:
```javascript 
const timing = getTiming();
```
Response:

![alt Output][OP]

[OP]: response.png "Response from timing getTiming()"

---
_Source: https://npm.io/package/window-performance-statistics · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
