Adsense
Popular Posts
- MySQL workbench -"Could not decrypt password cache"
- mod_auth_cas.so error: undefined symbol: SSL_connect
- JavaScript, remove trailing insignificant zeros after toFixed function
- Set Windows path command line
- JavaScript Arrays and Associate Arrays
- Design date and signature box in Latex
- Install APXS in Redhat Linux
- super(props) in React
- jQuery, toggle the display
- PHP function for input sanitizing
Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts
Monday, December 16, 2013
Measurement webpage performance
To measure webpage performance, we can use window.performance.timing object.
To calculate loading time, we can use loadEventEnd - navigationStart under use window.performance.timing.
Example code
<script type='text/javascript'>
function loadingtime() {
if (!!window.performance) {
// navigation time is loadEventEnd - navigationStart
var timingData = window.performance.timing;
document.querySelector("#loadtime").innerHTML = (timingData.loadEventEnd - timingData.navigationStart);
}
else {
document.querySelector("#message").innerHTML = "<p>This browser does not support the <code>performance</code> object</p>";
}
}
function init() {
setTimeout(loadingtime, 500);
}
window.onload = init;
</script>
<div id="message">
<p><span class="label">Load Time: </span><span id="loadtime"></span>ms</p>
</div>
Subscribe to:
Posts (Atom)