asp.net 3.5以上的scriptmanager

如果在一个应用中,调用很多JS文件,性能上有可能不大好,
在ASP。NET 3。5以上,有scriptmanager可以管理,比如:
有两个JS

//Jscript1.js
function Task1() {
    alert('task1');
    }


////Jscript1.js
function Task2() {
    alert('task2');
}

<form id="form1" runat="server">
       <asp:ScriptManager ID="myScriptManager" runat="server" >
           <Scripts>
               <asp:ScriptReference Path="~/JScript1.js" />
               <asp:ScriptReference Path="~/JScript2.js" />
           </Scripts>
       </asp:ScriptManager>
       <script language="javascript" type="text/javascript">
           Task1();
           Task2();          
       </script>
   </form>

这个在FIREFOX下可以看到性能为:


5次请求,
而用了scriptmanger后
<form id="form1" runat="server">
        <asp:ScriptManager ID="myScriptManager" runat="server" >
            <CompositeScript>
                <Scripts>
                    <asp:ScriptReference Path="~/JScript1.js" />
                    <asp:ScriptReference Path="~/JScript2.js" />
                </Scripts>
               
            </CompositeScript>
        </asp:ScriptManager>
        <script language="javascript" type="text/javascript">
            Task1();
            Task2();          
        </script>
    </form>

为发现只有4次请求,因此可以考虑下

你可能感兴趣的:(.net,asp.net,asp,firefox)