https://github.com/js-bits/performance
Cross-environment (nodejs/web) performance object
https://github.com/js-bits/performance
Last synced: about 1 year ago
JSON representation
Cross-environment (nodejs/web) performance object
- Host: GitHub
- URL: https://github.com/js-bits/performance
- Owner: js-bits
- Created: 2021-04-21T22:21:13.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T03:09:13.000Z (almost 3 years ago)
- Last Synced: 2025-03-15T22:08:47.136Z (about 1 year ago)
- Language: JavaScript
- Size: 520 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cross-environment (nodejs/web) performance object
This package exports `window.performance` object in a browser and built-in [Performance measurement APIs](https://nodejs.org/api/perf_hooks.html) module in a Node.js environment. Which is helpful when you develop a package compatible with both environments and use `performance` for some measurements. Allows to avoid conditional imports.
## Installation
Install with npm:
```
npm install @js-bits/performance
```
Install with yarn:
```
yarn add @js-bits/performance
```
Import where you need it:
```javascript
import performance from '@js-bits/performance';
```
or require for CommonJS:
```javascript
const performance = require('@js-bits/performance');
```
## How to use
```javascript
const t = performance.now();
```
## Notes
- Minimal size (bytes) in a browser since [Performance API](https://developer.mozilla.org/en-US/docs/Web/API/Performance_API) is natively supported. Does not include any polyfills.