Simple way to collect and look at your website performance metrics quickly, that supports budgeting and adding custom metrics.
Learn More Install Star on Github<!DOCTYPE html> | |
<html> | |
<head> | |
<title>PerfBar</title> | |
<meta charset='utf-8'> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css"> | |
</head> | |
<body> | |
<h1>Hello Wrold!</h1> | |
<!-- NOTE: Place the script at the bottom of the page for better performance https://developer.yahoo.com/blogs/ydnfiveblog/high-performance-sites-rule-6-move-scripts-bottom-7200.html --> | |
<!-- This is all you need to start using PerfBar! --> | |
<script type="text/javascript" src="http://perfbar.khalidlafi.com.global.prod.fastly.net/perfbar-0.0.2.min.js"></script> | |
<script type="text/javascript"> | |
perfBar.init({ | |
// list of the built-in metrics http://wpotools.github.io/perfBar/#list | |
budget: { | |
// the key is the metric id | |
'loadTime': { | |
max: 200 | |
}, | |
'redirectCount': { | |
max: 1 | |
}, | |
'globalJS': { | |
min: 2, | |
max: 5 | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Every metric must have a unique id or addMetric
will return an error.
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>PerfBar</title> | |
<meta charset='utf-8'> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css"> | |
</head> | |
<body> | |
<h1>Hello Wrold!</h1> | |
<!-- NOTE: Place the script at the bottom of the page for better performance https://developer.yahoo.com/blogs/ydnfiveblog/high-performance-sites-rule-6-move-scripts-bottom-7200.html --> | |
<script type="text/javascript" src="http://perfbar.khalidlafi.com.global.prod.fastly.net/perfbar-0.0.2.min.js"></script> | |
<script type="text/javascript"> | |
perfBar.init(); | |
var err = perfBar.addMetric({ | |
id: 'Test', | |
label: 'Test new metric', // human readable name | |
value: 18, | |
budget: { | |
max: 20, | |
min: 1 | |
} | |
}); | |
if ( !err ) console.log('Woho , no errors all is ok!'); | |
</script> | |
</body> | |
</html> |
.updateMetric(id, updateObject)
id
: is the metric id
updateObject
: is an object that contains the new values for the metric. You can update the budget
, label
, value
, unit
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>PerfBar</title> | |
<meta charset='utf-8'> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css"> | |
</head> | |
<body> | |
<h1>Hello Wrold!</h1> | |
<!-- NOTE: Place the script at the bottom of the page for better performance https://developer.yahoo.com/blogs/ydnfiveblog/high-performance-sites-rule-6-move-scripts-bottom-7200.html --> | |
<script type="text/javascript" src="http://perfbar.khalidlafi.com.global.prod.fastly.net/perfbar-0.0.2.min.js"></script> | |
<script type="text/javascript"> | |
perfBar.init(); | |
var err = perfBar.addMetric({ | |
id: 'testId', | |
label: 'Test new metric', // human readable name | |
value: 18, | |
budget: { | |
max: 20, | |
min: 1 | |
} | |
}); | |
if ( !err ) console.log('Woho , no errors all is ok!'); | |
// Updating metric - this works for all the metrics even the built-in ones. | |
perfBar.updateMetric('testId', { | |
value: 5 | |
}) | |
</script> | |
</body> | |
</html> |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>PerfBar</title> | |
<meta charset='utf-8'> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css"> | |
</head> | |
<body> | |
<h1>Hello Wrold!</h1> | |
<!-- NOTE: Place the script at the bottom of the page for better performance https://developer.yahoo.com/blogs/ydnfiveblog/high-performance-sites-rule-6-move-scripts-bottom-7200.html --> | |
<script type="text/javascript" src="http://perfbar.khalidlafi.com.global.prod.fastly.net/perfbar-0.0.2.min.js"></script> | |
<script type="text/javascript"> | |
perfBar.init(); | |
perfBar.disable('loadTime') // it will remove the metric from the bar | |
perfBar.enable('loadTime') // it will re-add the metric to the bar, with the same old value, budget, label, unit. | |
</script> | |
</body> | |
</html> |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>PerfBar</title> | |
<meta charset='utf-8'> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css"> | |
</head> | |
<body> | |
<h1>Hello Wrold!</h1> | |
<!-- NOTE: Place the script at the bottom of the page for better performance https://developer.yahoo.com/blogs/ydnfiveblog/high-performance-sites-rule-6-move-scripts-bottom-7200.html --> | |
<script type="text/javascript" src="http://perfbar.khalidlafi.com.global.prod.fastly.net/perfbar-0.0.2.min.js"></script> | |
<script type="text/javascript"> | |
// this option is good if you're lazy loading the PerfBar script. | |
// Because without it the Navigation timing metrics won't work since they are attached to the onload event | |
perfBar.init({lazy: true}); | |
</script> | |
</body> | |
</html> |
Page Load time. It's calculated by subtracting loadEventStart
and navigationStart
. The Default max is 5000 ms
Id: loadTime
Unit: ms
Budget – Max: 5000
Source: Navigation Timing API
The time it takes to recieve the first byte from server.
Id: latency
Unit: ms
Budget – Max: 50
Source: Navigation Timing API
The time it takes the browser to paint the first frame.
Id: FirstPaint
Unit: ms
Budget – Max: 100
Source: Chrome.loadTimes and IE timing
NOTE: This metric does not work on Firefox, unfortunately :(
The implementation of this metric is taken from timing.js, thanks Addy!
It's the total number of HTTP/HTTPS requests made by the page.
Id: numReqs
Source: Resource timing API
The time the page takes to do the front end work, this start after responseEnd
event and it ends when the onload
event fires.
Id: frontEnd
Unit: ms
Budget – Max: 80% of the total page load time, following Steve's Golden rule
Source: Navigation Timing API
The time it takes to get the full response from the server, this start at navigationStart
event and it ends at responseEnd
event.
Id: backEnd
Unit: ms
Budget – Max: 20% of the total page load time, following Steve's Golden rule
Source: Navigation Timing API
The time it takes the browser to recieve the full response, this start at responseStart
event and it ends at responseEnd
event.
Id: respnseDuration
Unit: ms
Source: Navigation Timing API
The time it takes server to respond after sending a request to it, this start at requestStart
event and it ends at responseStart
event.
Id: requestDuration
Unit: ms
Source: Navigation Timing API
How many redirects it took you to get to this page?
Id: redirectCount
Source: Navigation Timing API
The amout of time it took the load event to finish.
Id: loadEventTime
Unit: ms
Source: Navigation Timing API
Time for the DOM content to be loaded.
Id: domContentLoaded
Unit: ms
Source: Navigation Timing API
The amount of time that takes the browser to process the whole page.
Id: processing
Unit: ms
Source: Navigation Timing API
The total number of DOM elements.
Id: numOfEl
Source: DOM
The total number of the CSS files in the page.
Id: cssCount
Source: DOM
The total number of the JavaScript scripts in the page.
Id: jsCount
Source: DOM
The total number of images in the page.
Id: imgCount
Source: DOM
The total number of the data URI images in the page.
Id: dataURIImagesCount
Source: DOM
The total number of the inlined CSS in the page.
Id: inlineCSSCount
Source: DOM
The total number of the inlined JavaScript in the page.
Id: inlineJSCount
Source: DOM
The total number of the CSS files loaded from a 3rd party host.
Id: thirdCSS
Source: DOM
The total number of the JavaScript files loaded from a 3rd party host.
Id: thirdJS
Source: DOM
The current page has PerfBar in it.