2012-08-13 72 views

回答

4

您可以通過在剃鬚刀視圖中使用TimeScript命令來計算客戶端腳本執行時間。從Sample.MVC

實施例:

<head> 
    @this.InitClientTimings() 
    @this.TimeScript("jQuery 2.0.3", @<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" type="text/javascript"></script>) 

    @using (profiler.Step("<head> rendering")) 
    { 
    <title>@ViewBag.Title - MVC MiniProfiler Demo</title> 
    @(this.TimeScript("Our CSS", @<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />)) 
    @RenderSection("head", required:false) 
    } 
</head> 

這裏所用的時間加載jQuery和CSS腳本被定時。您當然可以使用此功能注入任何客戶端代碼。