iframe :
src about:blank ,- ,
onload ,src .
frameTimer, :
- a
init, </body> - a
measure , , .
, :
{
iframes: {
'http://google.co.jp/': 1241159345061,
'http://google.com/': 1241159345132,
'http://google.co.uk/': 1241159345183,
'http://google.co.kr/': 1241159345439
},
document: 1241159342970
}
, , diff .
javascript (frameTimer.js):
var frameTimer = ( function() {
var iframes, iframeCount, iframeSrc, results = { iframes: {} };
return {
init: function() {
iframes = document.getElementsByTagName("iframe"),
iframeCount = iframes.length,
iframeSrc = [];
for ( var i = 0; i < iframeCount; i++ ) {
iframeSrc[i] = iframes[i].src;
iframes[i].src = "about:blank";
}
},
measure: function( callback ) {
results.document = +new Date;
for ( var i = 0; i < iframeCount; i++ ) {
iframes[i].onload = function() {
results.iframes[ this.src ] = +new Date;
if (!--iframeCount)
callback( results )
};
iframes[i].src = iframeSrc[ i ];
}
}
};
})();
html (frameTimer.html):
<html>
<head>
<script type="text/javascript" src="frameTimer.js"></script>
</head>
<body onload="frameTimer.measure( function( x ){ alert( x.toSource() ) } )">
<iframe src="http://google.com"></iframe>
<iframe src="http://google.co.jp"></iframe>
<iframe src="http://google.co.uk"></iframe>
<iframe src="http://google.co.kr"></iframe>
<script type="text/javascript">frameTimer.init()</script>
</body>
</html>
( ) jQuery, .