Skip to content

Instantly share code, notes, and snippets.

@akai
Created December 30, 2011 03:33
Show Gist options
  • Save akai/1537638 to your computer and use it in GitHub Desktop.
Save akai/1537638 to your computer and use it in GitHub Desktop.
使用“标准”图片进行监控对比
// via http://www.infoq.com/cn/presentations/wh-dianping-web-develop-road
var idcUrl = 'http://domian.com/test.jpg?' + Math.random();
document.getElementById('top').innerHTML = '<img src="'
+ idcUrl + '" onload="idc(this.src, '
+ (new Date().getTime()) + ')" />';
function idc(url, start) {
var loadTime = new Date().getTime() - start;
_gaq.push(['_trackEvent', 'IDCLoadTime', url, '', loadTime]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment