ASP.NET Bundling, Minification & Resource Optimization

A complete look into the bundling and minification framework available in the ASP.NET web optimization library. Learn how to efficiently optimize your website resources and assets without comprising the way you want to develop. ASP.NET makes bundling and minification incredibly easy and leaves no reason not to ensure your web application is fully optimized.
Course info
Rating
(129)
Level
Intermediate
Updated
Dec 11, 2013
Duration
4h 22m
Table of contents
Understanding Optimizations
Basic Optimizations
Advanced Optimizations
Extending Optimizations
Architecting Optimizations
Testing Optimizations
Description
Course info
Rating
(129)
Level
Intermediate
Updated
Dec 11, 2013
Duration
4h 22m
Description

A complete look into the bundling and minification framework available in the ASP.NET web optimization library. Learn how to efficiently optimize your website resources and assets without comprising the way you want to develop. ASP.NET makes bundling and minification incredibly easy and leaves no reason not to ensure your web application is fully optimized. Walk through basic optimization setup against a demo application in both Web Forms and MVC. Then, work to enhance the demo application by adapting the bundling framework for ignoring files, ordering files, and adding CDN scripts with a fallback. You will see how to begin extending the optimization library with your own custom transforms to harness great flexibility. We will take customizations a step further and consider using custom bundles to consolidate and inject resources, enumerations and templates to the client. Finally, we will dive into unit testing your optimization configurations and extensions and the importance of doing so in a team environment.

About the author
About the author

Travis is a senior architect and lifelong developer with a passion for building, leading, and training. A periodic blogger, and local community speaker, Travis mainly focuses on architecture and development patterns in the .NET stack, but has a special place in his heart specifically for web and JavaScript development.

Section Introduction Transcripts
Section Introduction Transcripts

Basic Optimizations
Hi, and welcome to this module on basic optimizations in the ASP. net web optimization library. We're going to look at all the basic information required to set up some standard optimizations around the bundling and minifying inside an ASP. net application. By the end of this module, you should be able to easily add bundling and minification optimizations into your own web application with relative ease. We're going to start off by simply reviewing some of the default templates that can be found in Visual Studio 2012 when creating a new MVC web application. Each one of the templates is slightly unique and offer excellent starting points for bundling and minification. Then, we will introduce a common application, which we will be working with throughout this and subsequent modules of this course as we slowly transform it and use it as our testing ground for demos with the system. web. optimization framework. Inside of our demo bookstore application, we will look at simple bundle declarations and consumption. We will examine the differences between consumption from an MVC versus a web forms application. We will also look at the internal workings of the framework and exactly how requests get action and return the results. Finally, we will review how cache busting is automatically handled by the framework through the use of versioning and how you can take advantage of that out-of-the-box.

Advanced Optimizations
Hi, and welcome to this module on Advanced Optimizations in the ASP. NET Web Optimization Library. This module will focus on more advanced, out-of-the-box functionality that you can use with the Optimization Library to get maximum efficiency with very little code. The features of the Optimization Library that we will review include - ignoring of certain files when optimizations are enabled or disabled, how certain file extension replacements are customized, alongside more details in the wild card character and version moniker that we have already seen used. You can also specify your own custom file orders for your application, but if you don't, there are certain defaults already in place you need to be aware of. Content Delivery Networks are often an overlooked consideration for many people, but is very easy to integrate with your bundles. However, what are the real benefits of using a CDN in your application? And finally, we'll take a look at the new bundle child class that offers a lot more than convenience for Dynamic Folder Bundling.

Extending Optimizations
Hi, and welcome to this module on Extending Optimizations in the ASP. NET Web Optimization Library. While much of the module is based on the API given to us by the library, now we can take some time to talk about how you can write custom code to extend the library. I think you'll find that it opens up a complete new set of ideas that you can utilize the Optimization Library for. By the end of this module, you should be able to easily extend the library by writing powerful custom transformations. We will start it off by discussing how you can create your own Custom Convenience Bundles, like the Script and StyleBundle classes we've already seen. Then we'll spend some time looking at Custom Transformations, which is where the real power of the library lives. We'll then use Custom Transformations and look at how intermediate languages could be integrated using Pre-Processor Transforms for libraries like CoffeeScript and LESS. CSS URL Rewriting is something to be careful of in the out-of-the-box defaults, but we can eliminate that risk pretty easily. And finally, we'll take a look at bootstrapping our custom optimizations by incorporating the Bundle Transformer NuGet Package.

Architecting Optimizations
Hi, and welcome to this module on Architecting Optimizations in the ASP. NET Web Optimization Library. We have spent a great deal of time focusing on working with customizing the Optimization Library components. With this power comes great responsibility though. You need to consider how to integrate and architect your optimizations in your own applications. We'll take some time to cover some topics related to bundling that mostly correlate to your application design and architecture. Depending on the size of your project, these concerns can grow quite quickly. First, before you begin bundling, you likely wondered or were asked at one point, what about Asynchronous Module Definitions, or AMD, instead of bundling? Let's discuss AMD and its comparison to the bundling components. We should have further conversation on organizing your code and scripts and how this could affect the efficiency of your bundle integration and ease of development. A lot of time was spent on Bundling stylesheets and JavaScript files, but the bundling components can be used to consolidate many other useful things in your application, like resources and even HTML views. For example, we can consider the efficiencies of bundling our server side resources into JavaScript objects for access on the client in one centralized location. As well, we can look at the possibility of synching our enumeration server types that are required on the client into JavaScript objects too. And, we'll discuss how you may want to consolidate HTML Templates into a single bundle request.

Testing Optimizations
Hi, and welcome to this module on Testing Optimizations in the ASP. NET Web Optimization Library. In the end, the best code is always the code that lends itself easily to adding automated tests in the form of both integration and unit tests. The Virtual Path Provider makes an appearance in the Optimization Library and gives us the true power to retrieve resources from virtually any location we can imagine, including databases, the manifest stream, and we can take advantage of the Virtual Path Provider to give us the ability to create powerful unit and integration tests that become essential in your long-term maintenance of your application.