The features handle exactly the two areas to improve the overall page loading time. Instead of making independent requests to every script file, they make only one request and download all the script necessary or CSS data at once. Next, they minify the CSS and files that results in a compressed form of content. The compressed content is downloaded on a client side, meaning that fewer bytes travel over the wire.
Minification does various different code optimizations to CSS or scripts, like removing unnecessary comments and white space and shortening variable names to a single character. The general idea behind to bundle is to concatenate multiple programs of the same type to one file, thus getting a single big resource instead of several small resources. Minifying takes bundling one step further through adding model-based compression to content. Besides removing white space, to minifying typically shortens variable names and other identifiers and removes unused pieces.
The resulting content is a resource like any other with a URL, thus no modification of the client side is required to accommodate them. Moreover, the resources are could be thoroughly cached and may be compressed like any other contents.
Steps to use the two features:
1. Open Visual Studio and make a new ASP.NET MVC app based on empty template. Right click on the References folder and choose Manage NuGet packages menu option. In the NuGet packages dialog, look for Microsoft ASP.NET web optimization framework and install it. It includes all assemblies which are important to enable and use the two features.
2. Add HomeController and Index View to the app just like any ASP.NET MVC app. Add a bunch of script data to the Scripts folder. Drag and drop the writing documents from the Scripts folder to the head section of the Index view so the script references would be added.
3. Run the app and check and take not of the results in Chrome Developer Tools. Based on the machine speed and calligraphy files version, the results could vary. Make certain that the Div displays the message as expected. This is a normal execution of the app and does not use any of the two features.
4. Open Global.asax file and write the code marked in bold letters. Then create an instance of ScriptBundle class, which represents a bundle of script files that could be accessed at a specified URL in the constructor. The URL is a virtual one and does not point to any physical file. Just like ScriptBundle, there's a StyleBundle class which represents a cluster of files. The code adds all the programs necessary to the ScriptBundle with the Include() method. The newly created cluster is added to the BundleTable object's Bundles collection. The EnableOptimizations property turns the two to On (true) or Off (false).