Question

I am using SquishIt MVC framework for bundling and minification of the js and css components present in the application. The code is as mentioned below:

public static class HTMLHelperExtensions
{
  public static MvcHtmlString PackageLibs(this HtmlHelper htmlHelper)
  {
    var client = Bundle.JavaScript() 
     .Add("~/scripts/jquery-1.7.1.min.js")
     .Add("~/scripts/jquery-ui-1.8.17.min.js")
     .Render("~/scripts/combined.js");

    return new MvcHtmlString(client);
  }
}

I am invoking the method : HTMLHelperExtensions from the layout page.

<%= HTMLHelperExtensions() %>

I want to use the defer attribute to boost the JavaScript performance of a web page.

Can anyone help me to know the usage of the defer attribute? I would like to know also is the usage of webworker useful here.

Thanks & Regards, Santosh Kumar Patro

Was it helpful?

Solution

To render with deferred load, change your bundle setup like so:

 var client = Bundle.JavaScript() 
     .Add("~/scripts/jquery-1.7.1.min.js")
     .Add("~/scripts/jquery-ui-1.8.17.min.js")
     .WithDeferredLoad()
     .Render("~/scripts/combined.js");

Web workers seem like overkill for something as trivial as script loading IMO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top