C# tip, MVC, Non-functional Requirements, Performance

Performance in ASP.net and C# – Bundling and Minification

Another quick post – a really useful feature of MVC that everyone has heard of…and then they seem to forget to do it in practice.

Don’t forget about Bundling and Minification – Rick Anderson explains here how to do it and why it’s important, and a picture tells a thousand words when you see network timings before and after switching on bundling.

Remember, if you don’t see bundling working on your MVC project:

  1. Make sure that the compilation element in your Web.config’s system.web node has the debug = "false";
  2. Check the RegisterBundles class and check if the BundleTable.EnableOptimizations value is set.
    • I don’t actually like this being in my RegisterBundles class – I’d prefer to set this through configuration and not have it embedded in my C# code;
  3. Make sure that the bundling/minification configuration that you’ve set up for your development environment isn’t being copied across to your other environments – you might have planned to debug locally, but you probably don’t want that preference copied across to your acceptance, demonstration or production environments.

This is a really quick and simple way to improve your site’s performance – try it!