Consolidate and minimize MVC4 with CDN

I know the benefits of CDN, and I also understand the benefits that MVC4 Bundling and Minification offers.

I want to know that you can combine the benefits of combining and minimizing MVC4 and CDN. I mean, can we publish a linked and smaller script or css with a CDN, and then in the views we access the mini version via the CDN URL?

+4
source share
2 answers

Yes, it’s quite possible and good practice to publish a Minified script for your CDN. I regularly see both on different CDNs. This allows the developer to choose which version they need.

...then in views we access the minified version through CDN url? 

Yes, you will get access to the mini version with the CDN URL.

+2
source

You can combine combining and minimizing MVC4 with CDN

http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification

Code from the page above:

 public static void RegisterBundles(BundleCollection bundles) { //bundles.Add(new ScriptBundle("~/bundles/jquery").Include( // "~/Scripts/jquery-{version}.js")); bundles.UseCdn = true; //enable CDN support //add link to jquery on the CDN var jqueryCdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"; bundles.Add(new ScriptBundle("~/bundles/jquery", jqueryCdnPath).Include( "~/Scripts/jquery-{version}.js")); // Code removed for clarity. } 
0
source

Source: https://habr.com/ru/post/1500999/


All Articles