locked
How to decrease page load time (combine javascript on application publish?) RRS feed

  • Question

  • User-1262787652 posted

    Page created using ASP .NET MVC 2  takes 1.7 sec to load. It contains 13 js files as shown below. Firebug shows that every js file load returns 304 response but since there are 13 files it may increace page load time a lot. Chrome audit red alert recomments to combine js files.

    How to combine them to single file using ASP.NET MVC 2 automatically or other way to decrease load time ? There should be separate js files in project to allow to replace them but those should delivered as single js file probably.

    jqgrid, jquery, jquery-ui, tinymce and some jquery plugin js files are used as shown below. Visual Web Developer Express 2010 is used. Application is running under Mono 2.10/Apache and under Windows/IIS

    Site.Master contains:

     

            <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
            <!DOCTYPE html>
            <html>
            <head runat="server">
                <meta charset="utf-8" />
                <meta http-equiv="X-UA-Compatible" content="IE=edge" />
                <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.1" />
                <link rel="stylesheet" href="../../themes/redmond/jquery-ui-1.8.12.custom.css" type="text/css" />
                <link href="../../Scripts/jqgrid/css/ui.jqgrid.css" rel="stylesheet" />
                <link href="../../Content/Css/Site.css" rel="stylesheet" />
                <asp:ContentPlaceHolder ID="HeadContent" runat="server" />
                <title>
                    <asp:ContentPlaceHolder ID="TitleContent" runat="server" />
                </title>
                <script type="text/javascript">
                    "use strict";
                    var BASE_URL = '<%= ResolveUrl("~/") %>';
                </script>
                <script src="<%= Url.Content("~/Scripts/jquery/jquery-1.7.1.js")%>" type="text/javascript"></script>
                <script src="<%= Url.Content("~/Scripts/jquery-ui-git.js")%>" type="text/javascript"></script>
                <script src="<%= Url.Content("~/Scripts/i18n/jquery.ui.datepicker-et.js")%>" type="text/javascript"></script>
                <script src="<%= Url.Content("~/Scripts/jquery.contextmenu-fixed2.js")%>" type="text/javascript"></script>
                <% if (CurUser.GetLanguage() == "EST")
                   { %>
                <script src="<%= Url.Content("~/Scripts/jqgrid/js/i18n/grid.locale-et.js")%>" type="text/javascript"></script>
                <% }
                   else
                   { %>
                <script src="<%= Url.Content("~/Scripts/jqgrid/js/i18n/grid.locale-en.js")%>" type="text/javascript"></script>
                <% } %>
                <script type="text/javascript">
                    $.jgrid.no_legacy_api = true;
                    $.jgrid.useJSON = true;
            </script>
            <script type="text/javascript" src="<%= Url.Content("~/Scripts/jqgrid/jquery.jqGrid.src-multiselect1-deleteandsortpatches.js")%>"></script>
            <script type="text/javascript" src="<%= Url.Content("~/Scripts/jqgrid/jQuery.jqGrid.dynamicLink.js")%>"></script>
            <script src="<%= Url.Content("~/Scripts/json2.js")%>" type="text/javascript"></script>
            <script src="<%= Url.Content("~/Scripts/jquery.form.js")%>" type="text/javascript"></script>
            <script src="<%= Url.Content("~/Scripts/TinyMCE/tiny_mce_src.js")%>" type="text/javascript"></script>
            <script src="<%= Url.Content("~/Scripts/TinyMCE/jquery.tinymce.js")%>" type="text/javascript"></script>
            <script src="<%= Url.Content("~/Scripts/myscripts.js")%>" type="text/javascript"></script>
            <script type="text/javascript">
            var 
                $grid;
        	$(function() {
                "use strict";
        
        <% if (TempData["Message"]!=null) {
        setTimeout( function() {
           showMessage ( '<%= TempData["Message"] as string %>');
        ...

    Sunday, September 23, 2012 8:18 AM

Answers

All replies