{"id":27882,"date":"2015-10-09T12:11:31","date_gmt":"2015-10-09T06:41:31","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=27882"},"modified":"2015-10-09T12:11:31","modified_gmt":"2015-10-09T06:41:31","slug":"bundling-and-minification-features-in-asp-net-4-5","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/bundling-and-minification-features-in-asp-net-4-5\/","title":{"rendered":"Bundling and Minification Features in Asp.Net 4.5"},"content":{"rendered":"<p><strong>Induction <\/strong><\/p>\n<p>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.\u00a0 To solve this problem ASP.NET 4.5 provide a new feature Bundling and minification \u2013 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 ,\u00a0 So ASP.Net 4.5 provide a new feature bundle and minify JavaScript and CSS file.<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>What is Bundling and Manification?<\/strong><\/p>\n<p>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\u00a0 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<\/p>\n<p>\u00a0\u00a0\u00a0 &lt;script type=&#8221;text\/javascript&#8221;\u00a0 src=&#8221;\/JS\/jquery-1.7.2.min.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>\u00a0\u00a0\u00a0 &lt;script type=&#8221;text\/javascript&#8221;\u00a0 src=&#8221;\/JS\/jquery.easing.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>\u00a0\u00a0\u00a0 &lt;script type=&#8221;text\/javascript&#8221;\u00a0 src=&#8221;\/JS\/jquery.mousewheel.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>How to use Bundling and Manification\u00a0 in our website :<\/strong><\/p>\n<p>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.<\/p>\n<p>&lt;%@ Application Language=&#8221;C#&#8221; %&gt;<\/p>\n<p>&lt;%@ Import Namespace=&#8221;System.Web.Optimization&#8221; %&gt;<\/p>\n<p>\u00a0\u00a0 \u00a0 public void Application_Start(object sender1, EventArgs e1)\u00a0 \u00a0 {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Code that runs on application startup<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 BundleTable.Bundles.RegisterTemplateBundles();\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0 }<\/p>\n<p>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.<\/p>\n<p>&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;\/JS&#8221;&gt;&lt;\/script&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Induction 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.\u00a0 To solve this problem ASP.NET 4.5 provide a new feature Bundling and minification \u2013 Whenever user request to open any website from the any browser , at same time [&hellip;]<\/p>\n","protected":false},"author":410,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[1],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/27882"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/410"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=27882"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/27882\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=27882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=27882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=27882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}