MVC Framework Bundling - MVC Framework

What is MVC Framework Bundling?

Bundling and Minification are the two performance improvement techniques which improve the application request load time. Many of the present main browsers restrict the number of concurrent connections per hostname to six. This means that at a time, all the additional requests will be queued by the browser.

Enable Bundling and Minification

For enabling bundling and minification in the MVC application, open Web.config file inside your solution and search for compilation settings under system.web

By default, debug parameter will be set to true, which means that bundling and minification is disabled. Set this parameter to false.

Bundling

For imporoving the performance of the application, ASP.NET MVC offers inbuilt features to bundle multiple files into a single file, which in turn improves the page load performance because of fewer HTTP requests.

Bundling is a simple logical group of files which can be referenced by unique name and loaded with a single HTTP request.

By default, MVC application's BundleConfig (located inside App_Start folder) comes with below code

Above code basically bundles all the CSS files present in Content/themes/base folder into a single file.

Minification

Minification is an another performance improvement technique in which, it optimizes the javascript, css code by shortening the variable names, removing unnecessary white spaces, line breaks, comments, etc. This in turn reduces the file size and helps the application to load faster.

Minification with Visual Studio and Web Essentials Extension

For using this option, user should have to first install the Web Essentials Extension in their Visual Studio, then right-click on any css or javascript file, it will show an option for creating a minified version of that file.

bundling

Thus, having a css file named Site.css can create its minified version as Site.min.css.

Next time when the application runs in the browser, it will bundle and minify all the css and js files, by improving performance of the application.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

MVC Framework Topics