Bundling and Minification Features in Asp.Net 4.5

09 / Oct / 2015 by Harsh Verma 0 comments


As we know performance of website is major impact in website development, So we are all tried to increase website speed and reduce server resource.  To solve this problem ASP.NET 4.5 provide a new feature Bundling and minification – Whenever user request to open any website from the any browser , at same time there are multiple request are send from browser to server and response for each request such as CSS, JavaScript and J-Query ,  So ASP.Net 4.5 provide a new feature bundle and minify JavaScript and CSS file.


What is Bundling and Manification?

Bundling and Manification is feature to bundling multiple request of javascript and css file into a bundle, its mean one request for all files and Performance is further improve to  remove white space and comment from this bundle file , So with the help of this feature we can remove server load and increase website speed

    <script type=”text/javascript”  src=”/JS/jquery-1.7.2.min.js”></script>

    <script type=”text/javascript”  src=”/JS/jquery.easing.js”></script>

    <script type=”text/javascript”  src=”/JS/jquery.mousewheel.js”></script>


How to use Bundling and Manification  in our website :

We have to call RegisterTemplateBundles() method on Application_Start handler of global.asax . that does the default bundling and minification for you. Bundling and minification to work you need to specify the URLs of the JavaScript and CSS files a bit differently.

<%@ Application Language=”C#” %>

<%@ Import Namespace=”System.Web.Optimization” %>

     public void Application_Start(object sender1, EventArgs e1)    {

        // Code that runs on application startup



Then we have to write only below one line in aspx file to call all Javscript files which are appear in JS folder . Then by default browser call one request for all Javascript files and these are automatic compressed and removed comments.

<script type=”text/javascript” src=”/JS”></script>


Leave a Reply

Your email address will not be published. Required fields are marked *