An open API service indexing awesome lists of open source software.

https://github.com/sofish/performance.js

calculate performance timing for web page
https://github.com/sofish/performance.js

Last synced: 11 months ago
JSON representation

calculate performance timing for web page

Awesome Lists containing this project

README

          

## Page Performance

### 1. Usage:

Install the `performance.js` file in the page, and listen to the `perf` event:

```html

window.addEventListener('perf', function(perf) {
console.log(perf.detail);
})

```

### 2. the `perf.detail` object

#### 2.1 properties

lookupdns, domain lookup for the source
waitingnetwork latency, waiting before page request start
receivingperiod between request start and request end
parsingdom parsing, from dom loading to dom complete
contentLoadedwe used to call it dom ready
pageLoadedfrom user agent start a lookup to load event start

#### 2.2 code to calculate out the properties

```js
[ 'lookup' , ['requestStart', 'navigationStart']],
[ 'waiting' , ['responseStart', 'requestStart']],
[ 'receiving' , ['responseEnd', 'responseStart']],
[ 'parsing' , ['domComplete', 'domLoading']],
[ 'contentLoaded' , ['domContentLoadedEventStart', 'navigationStart']],
[ 'pageLoaded' , ['loadEventStart', 'navigationStart']]
```

#### 2.3 performance life cycle chart

![performance life cycle chart](http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/timing-overview.png)

### 3. Testcase

run the `testcase.html` file, please!

### 4. License

(c) MIT License