Introduction
In this article I will take you through bundling and minification concepts and why to use and apply these standards in your code as a developer.
Agenda
- Overview
- Need | Analysis
- Comparative Study
• Before Web Optimization
• After Web Optimization
- Introduction
- Techniques
- Bundling
• Procedure
• Comparison
• Bundling | Features
- Minification
• Minification | Features
• Snippet
- Controlling
- Other Techniques
- Summary
Overview
Peoples are enjoying coding these days, they are ionate about coding. It doesn't matter what they code and in which language, the thing that really matters these days is code optimization and how efficiently and effectively your code performs certain required actions.
Need Analysis
As I explained, coding is now not an issue for developers these days, the main thing in a development environment is what your code will do and how effective it is in a real scenario.
In this article I will explain how to make our code efficient and work better depending on the required set of operations (I am explaining it the context of C#, you can also explore for your favorite language).
Comparative Study
This part of this article will show a real picture of web optimization. This picture contains two parts, the first part shows the web before ASP.NET web optimization techniques and the other picture shows the web scenario after the web optimization technique usage.
Here's the scenario.
Before WEB Optimization
[Scenario: 1]
After WEB Optimization
[Scenario: 2]
Introduction
For solving these types of complex problems and getting the desired result effectively, .NET provides super functionality for resolving all of these kinds of problems.
These factors are:
- Reducing request to the server
- Minimizing size of requests
Techniques
For handling those two issues, or we can say operations, for web framework optimization, we do use these two major techniques:
Bundling
In the bundling procedure ASP.NET minimizes or bundles the requests to the server depending on their functionality, so that the traffic at the sever can be easily handled.
The diagram below shows the comparative mechanism of how actually the requests were working before bundling and in the second diagram it shows the mechanism of handling requests, after use of the bundling concept.
Procedure
Comparison
The following shows the simple difference of functioning:
Before Bundling:
After Bundling:
Bundling Features
Some of the most useful features of bundling are as follows:
- Comes into light with ASP.NET 4.5
- Functionality Oriented
- Reduces traffic at the server
- Bundles the similar type of requests
- Improves page load operation
- Works with single resource
Minification
Minification is the process in which we try to minimize the size of requests to the server. It minimizes the load event handling at the server side.
Minification Features
Some most useful features of minification are as follows:
- Comes into light with ASP.NET 4.5
- Functionality oriented
- Reduces size of request to the server
- Improves performance of load event
Controlling
We can control these processes by simply enabling it in the web config file as in:
- <!-- Enabling-->
- <system.web>
- <compilation debug="true" targetFramework="4.0" />
- </system.web>
Then for enabling functionality we need to add this:
- public static void EnableBundles(BundleCollection bundles)
- {
- bundles.Add(new ScriptBundle("Path").Include(
- "Path-{version}.js"));
- BundleTable.EnableOptimizations = true;
- }
Other Techniques
Some other techniques of ASP.NET Web optimization are:
Summary
This article was a summary of Bundling and Minification. Mostly bundling I say, more of the functionality of the Minification operation will be added soon.
Until now, happy coding.