サーバーからページを受信してからページの読み込みにかかった時間をカウントしたいので、残りのloadEventEndとresponseEndを使用します。
しかし、私のコードではJSONPテクノロジも使用しており、「get 関数getJson()
」を使用すると、loadEventEnd は 0 を返します。
var getJson = function() {
document.getElementsByTagName('body')[0].appendChild((function(){
var sc = document.createElement('script');
sc.type = 'text/javascript'; sc.src = 'http://www.google.com/?callback=json123';
return sc;
})());
};
window.onload = new function(){
getJson(); // problem !!!
setTimeout(function(){
var t = performance.timing;
console.log(t.loadEventEnd - t.responseEnd);
}, 0);
}