performances
v2.0.0
Published
A wrapper for window Performace API
Downloads
4
Readme
PERFORMANCES
Description
A simple wrapper for Performance API
Usage
Basic usage is:
- Import the library from 'performances'
import Performances from 'performances'
;
- Instantiate the Performances object providing the window.performance object (optional) and invoke the method you want to use on it
var perf = new Performances(window.performance);
perf.getTotalTime(time => /* do stuffs with time */)
;
- You can use also the asJson method to get all info together:
perf.asJson(timeData => /*do stuffs with timeData*/)
- The method will provide an object with networkLatency, pageLoad and totalTime keys
Additionaly you can import single methods to have a lower impact on your bundle size:
- Import single methods you want to use
import getTotalTime from 'performances/lib/getTotalTime';
- Call the method providing the callback to call on retrieve
getTotalTime(time => /*do stuffs with time*/);
Note: using the single methods implies a compilation of the imported code.
Available methods
- getPageLoad
- getNetworkLatency
- getTotalTime