Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tuning MVC3 application that uses jquery?

I'm trying to tune up my MVC3 application that uses a lot of jquery libraries, including jqGrid.
I'd be interested to hear your best practices and performance tips and tricks if any. What you normally do for 'most' MVC3 based applications as a given.

Thank you

like image 801
SimpleUser Avatar asked Dec 29 '11 16:12

SimpleUser


3 Answers

Description

If tune means better loading you can do these 3 things. You could optimize the loading time up to 80% with theese techniques.

I suggest to use Fiddler2 to see how your changes perform.

  1. you should compress and combine your javascript files.
  2. you should use the OutputCache Attribute if possible
  3. you should remove unused ViewEngines

Sample

  1. Combine/Compress/Minify JS and CSS files in ASP.NET MVC
  2. MSDN: OutputCacheAttribute Class

    [OutputCache(Duration=60)]
    public ActionResult Index()
    {
        return View();
    }
    
  3. do this in global.asax

    protected void Application_Start()
    {
        // other stuff
    
        ViewEngines.Engines.Clear();
    
        // if you only use RazorViewEngine
        ViewEngines.Engines.Add(new RazorViewEngine());
    
        // if you only use WebFormViewEngine
        ViewEngines.Engines.Add(new WebFormViewEngine());
    }
    

More Information

  • Fiddler2
  • Improving ASP.NET MVC Application Performance
  • MSDN: OutputCacheAttribute Class
  • Combine/Compress/Minify JS and CSS files in ASP.NET MVC
like image 78
dknaack Avatar answered Nov 15 '22 06:11

dknaack


Following the Yahoo recommendations is a great way to optimize and speedup a website. Some of the tips are very easy to implement and could bring considerable performance gains.

Google have also published some great resources that I strongly invite you to read.

like image 32
Darin Dimitrov Avatar answered Nov 15 '22 04:11

Darin Dimitrov


Combining and minifying your scripts is a great start to cut down the response size and number of requests. Also, be sure not to include uneccessary plugins and code that won't be used on particular pages...

Article on the topic:

http://www.hanselman.com/blog/TheImportanceAndEaseOfMinifyingYourCSSAndJavaScriptAndOptimizingPNGsForYourBlogOrWebsite.aspx

For performance tuning on the server-side check out the Mini Profiler tool created and used by SO:

http://code.google.com/p/mvc-mini-profiler/

like image 42
Alex Avatar answered Nov 15 '22 04:11

Alex