Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 429
gidmanma Avatar asked Oct 09 '12 17:10

gidmanma


People also ask

Which of these is used for bundling and minification in an ASP NET core?

In ASP.NET Core apps, you bundle and minify the client-side resources during design-time using third party tools, such as Gulp and Grunt. By using design-time bundling and minification, the minified files are created prior to the application's deployment.

What is the benefit of bundling .js scripts into one file?

JavaScript bundling is an optimization technique you can use to reduce the number of server requests for JavaScript files. Bundling accomplishes this by merging multiple JavaScript files together into one file to reduce the number of page requests.

What is true about bundling and minification in asp net core?

Bundling and minification are two distinct performance optimizations you can apply in a web app. Used together, bundling and minification improve performance by reducing the number of server requests and reducing the size of the requested static assets.

What is the advantage of bundling in MVC?

The MVC provides us the two features to reduce the number of requests to access the resource file on the server i.e. Bundling and Minification. Bundling is one of the features of MVC. By implementing this, we can improve performance request load time.


2 Answers

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

like image 175
giftcv Avatar answered Oct 01 '22 23:10

giftcv


Bundling and minification provide 2 basic functionality in order to improve the performance of page load.

Bundling - Bundle all the provided scripts/ CSS in one file so that only browser need to load one file instead of multiple.
Note-> Generally browsers can may only 6 simultaneous requests to get resources from the server. Additional requests are queued by the browser for later processing. Hence, if we have multiple files then it may have to wait in the request queue.

Minification - Minification process generates a minified file by removing comments, extra white spaces and renames the variable names. So this reduces the file size and results in faster download.

like image 23
Ashish Shukla Avatar answered Oct 01 '22 22:10

Ashish Shukla