Based on a paper by Yaoqi Jia, Xinshu Dongy, Zhenkai Liang, and Prateek Saxena.
Presented by Mohammad Doleh
<img src="some-location-specific-resource" />
var image = document.createElement(‘img’);
image.src = url;
image.setAttribute(‘startTime’, (new Date().getTime()));
image.onload = function()
{
var endTime = new Date().getTime();
var loadTime = endTime - parseInt(this. getAttribute(‘startTime’));
}
var starTime, endTime, loadTime;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onloadstart = function()
{
startTime = (new Date()).getTime();
}
xmlhttp.onloadend = function()
{
endTime = (new Date()).getTime();
loadTime = endTime - startTime;
}
<img src="some-location-specific-resource" complete="complete"/>
function cached(url)
{
var image = document.createElement(‘img’);
image.src = url;
return image.complete || image.width+image.height > 0;
}
var page = document.createElement(‘iframe’);
page.setAttribute(‘startTime’, (new Date()).getTime());
page.onload = function ()
{
var endTime = (new Date()).getTime();
var loadTime = ( endTime - parseInt(this.getAttribute(‘startTime’)));
}
Browser | Image Load Time | CORS | <img> complete | <iframe> |
---|---|---|---|---|
Chrome | X | X | - | X |
Firefox | X | - | X | X |
Safari | X | - | X | X |
Opera | X | X | - | X |
IE | X | - | X | X |
google.com/maps/vt/pb=!1m5!1m4!1i15!2i12627!3i23720!4i128!2m1!1e0!3m3!5e1105!12m1!1e47!4e0