Navigation Performance API
Trying to make sense of this API. And possibly figure out if its possible to use it with XHR objects.
Attempt: #1.
HTML
<script src="https://raw.github.com/gist/1586738/3fbe15131982504dd292aaefc37705841c518abe/log.js"></script>
<ul class="a"></ul>
JavaScript
var times = function(timing) {
var properties = Object.getOwnPropertyNames(timing),
start = timing.navigationStart,
property, index, length = properties.length,
time,
duration;
// rebase timing from navigationStart so we can actually read the values
for (index = 0; index < length; index++) {
property = properties[index];
time = parseInt(timing[property], 10);
duration = time > 0 ? time - start : time;
// let's make it less verbose for now
if (duration > 0) {
log(property, duration);
$(".a").append("<li>" + property + duration + "</li>")
}
}
};
$(function() {
times(window.performance.timing);
});