Home > Enterprise >  Long page loading with own script js
Long page loading with own script js

Time:03-21

I have a page that takes a long time to load.

The reason is the js script code.

I set it to load asynchronously but it doesn't help.

Is there a way to do this? (In the script, I also refer to the Model from view.)

PageView:

@section Scripts{ 
    <script>
        //Lots of code with functions and references to DOM and AJAX
    </script>
}

_Layout:

@if (IsSectionDefined("Scripts"))
{
    @await RenderSectionAsync("Scripts", true)
}

The server returns a timeout error (works locally without any problem)

CodePudding user response:

You can use defer attribute <script defer> ... </script>. Also do you used await a lot?

CodePudding user response:

I use this syntax, wtihtout any problem

 @await RenderSectionAsync("Scripts", required: false)
  • Related