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
- Host: GitHub
- URL: https://github.com/sofish/performance.js
- Owner: sofish
- Created: 2013-01-04T08:06:06.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-03-26T00:50:28.000Z (over 13 years ago)
- Last Synced: 2025-04-23T16:04:07.585Z (over 1 year ago)
- Language: JavaScript
- Size: 104 KB
- Stars: 46
- Watchers: 8
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
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

### 3. Testcase
run the `testcase.html` file, please!
### 4. License
(c) MIT License