What is the benefit of ASP.NET bundling and minification in runtime?

gidmanma picture gidmanma · Oct 9, 2012 · Viewed 8.8k times · Source

I understand how to use asp.net's new bundling and minification features. They are helpful during development.

Is there any benefit to using them in a production deployment though? Would the system perform better if you just placed the bundled/minified files on the web server? It seems that overall, less code would run if they were just static files.

Note: I understand the benefit of having js/css bundled and minified. I am only questioning the value of using an active runtime process to generate those files in a production system as opposed to simply storing them on disk and referencing them as static files.

Answer

giftcv picture giftcv · Oct 9, 2012

Bundling and Minification is more useful in production than in development. It can significantly improve your first page hit download time.

  • Bundling reduces the number of individual HTTP requests to server by combining multiple CSS files and Javascript files into single CSS file and javascript file.

  • Minification reduces the file download size of CSS and javascript files by removing whitespace, comments and other unnecessary characters.

Such small advantages are more pronounced in a production environment than in development. So it is better to go with Bundling and Minification in production.

Specific to your question there is no palpable benefit in bundling/minification during runtime. This feature is there just to make the developer's work easier. So it is even better to go with manually bundled/minified assets in production if you are sure about what you are doing.

Update: According to MSDN there is a real benefit in bundling/minification during runtime

Bundling and minification in ASP.NET 4.5 is performed at runtime, so that the process can identify the user agent (for example IE, Mozilla, etc.), and thus, improve the compression by targeting the user browser (for instance, removing stuff that is Mozilla specific when the request comes from IE).`

The power of dynamic bundling is that you can include static JavaScript, as well as other files in languages that compiles into JavaScript.`

For example, CoffeeScript is a programming language that compiles into JavaScript