Satish Singh
Satish Singh

Reputation: 2339

Optimization of node_modules files in angular 4 with ASP.Net MVC, Visual Studio

I am using angular 4 in Visual studio 2017 with ASP.Net MVC. I tried to bundle all the files that required to load the page. E.g

public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new StyleBundle("~/bundles/css")
                .Include(
                          "~/Assets/css/LoaderCss.css",
                          "~/Assets/css/style.css",
                          "~/Assets/css/responsive.css"
                          ));

            bundles.Add(new ScriptBundle("~/script/scripts")
                .Include(
                          "~/" + ConfigurationManager.AppSettings["JsConfiguration"],
                          "~/Assets/script/jquery.min.js",
                          "~/node_modules/core-js/client/shim.min.js",
                          "~/node_modules/zone.js/dist/zone.js",
                         "~/node_modules/systemjs/dist/system.src.js",
                         "~/systemjs.config.js"
                          ));


            BundleTable.EnableOptimizations = true;
        }

and used on _LayoutPage.cshtml

@Styles.Render("~/bundles/css")
   @Scripts.Render("~/script/scripts")

But while loading the page all the required modules/files start loading that makes home page little slow. its because delay loading. e.g

enter image description here

Any idea how we can optimize this?

Upvotes: 0

Views: 304

Answers (1)

Indrit Kello
Indrit Kello

Reputation: 1313

Maybe you should start observing the elements, which of them is taking longer. Sometimes a "big" sized file can cause the delay.

For Prototypjs framework. You may use

document.observe('dom:loaded', function() {
    // do something here
});

from Prototype API documentation.

For node.js https://www.npmjs.com/package/observe

You may even use DeveloperTools in detail to find the "problematic" files.

Upvotes: 1

Related Questions