如何使用Jquery/Javascript计算Asp.net页面的加载时间?

Abh*_* B. 1 javascript jquery jquery-plugins dom-events

我正在开发一个Web应用程序,我想检查每个页面的加载时间或控制加载时间.

加载整个页面内容需要多长时间?
我想以微秒/秒计算asp.net页面加载时间,

我怎么知道使用Javascript/Jquery?

Pra*_*ana 5

以下脚本帮助您;

<SCRIPT LANGUAGE="JavaScript">
//calculate the time before calling the function in window.onload
beforeload = (new Date()).getTime();
function pageloadingtime()
{

     //calculate the current time in afterload 
    afterload = (new Date()).getTime();
     // now use the beforeload and afterload to calculate the seconds
    secondes = (afterload-beforeload)/1000;
     // If necessary update in window.status
    window.status='You Page Load took  ' + secondes + ' seconde(s).';
     // Place the seconds in the innerHTML to show the results
    document.getElementById("loadingtime").innerHTML = "<font color='red'>(You Page Load took " + secondes + " seconde(s).)</font>";

}

window.onload = pageloadingtime;
</SCRIPT>
Run Code Online (Sandbox Code Playgroud)

参考:http://www.dreamincode.net/code/snippet1908.htm

要么

如果你只想检查时间,请使用显示执行时间的firefox 的firebug.像这样的东西在此输入图像描述