Importance of bundling and minification in the development of .NET solutions

It is important to put the idea of bundling and minification in any .NET development process. Bundling and minification is really important and good for website performance. A developer of .NET has to find a way of making it so easy to manage so as not to require it manually.

Each methodology has their corresponding pros and cons. When specifying documents, one knows exactly what he is getting into the bundled and minified files. This requires more code. When adding directories does not require having to write more code, but the possibility exists for unwanted cipher in a bundled and minified file. Choosing between adding directories, folders or a combination is therefore a matter of personal preference.

Being a website developer nowadays is both challenging and interesting. From ASP.NET, one could apply parceling and minification of folders. Bundling refers to the method of combining numerous files to one so that amount of requests to load the page would be reduced. Minification on the other hand, refers to the process of removing unused spaces, comments, etc. to minimize the total size of files.

Both could be applied together, but they remain as independent processes. Depending on the requirement, one could decide to just create bundles or minify individual document. Typically, however, on production websites, there are not reasons to not bundle and minify all JavaScript and CSS textsw, except perhaps commons resources like jQuery. A bundled or minified source is quite difficult to read and step through, thus one may not want the two processes enabled.

A lot of frameworks provide both services with slightly different extensibility levels and different sets of features. Mostly however, they offer the same capabilities, thus picking one over the other is entirely a matter of preference. When writing an app, the natural choice to bundle and minify is the Microsoft ASP.NET web optimization framework which is available through NuGet.

Asp.net Minification

Below are the base points for making bundling and minification manageable.

1.Adding Microsoft ASP.NET web optimization framework. The framework is used for creating a minified version together with the specified bundles of the files. One could download and add file reference to the project from here.

2. Creating an XML file for defining portfolios binding. One could define two bundles to every page, one for common documents bundle that is required in every folio. Second is the binding for page specific portfolios. Page specific folders could include a JavaScript sheet and all JS controls that are added to a sheet.

3. As soon as bundles are defined in an XML FILE, a developer could add a bundling code in global.asax leaf. The code would handle the creating of bundles and reduction of files.

4. Adding a bundle reference to a sheet. If a debug mode is not false, then the Bundle data the only one that should be added to a page. Otherwise, every single file with normal file version should be added to the page, this makes it convenient for a develo9per to debug the JavaScript code.