Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mixing bundles and regular script?
Message
De
30/10/2012 09:08:20
 
 
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01555909
Message ID:
01556058
Vues:
25
This message has been marked as a message which has helped to the initial question of the thread.
>>>I don't understand why none of the CDN directories can be accessed directly and only individual files can be accessed. In this case, how can I reference them?
>>>
>>>Say, http://www.asp.net/ajaxlibrary/CDNjQueryUI190.ashx - each theme is a separate file. So, what am I supposed to do?
>>
>>Add them individually. You can bundle files on your own server but how do you expect a CDN to predict what files you require to be bundled? IAC it would be a mixed blessing since another web site may have already cached some of those files and reloading as part of a bundle would be wasteful.
>
>It makes sense. I guess we can always only use cdn with individual files, right?
>
>Yesterday I got rid of that new class I introduced on Friday and re-coded everything using the blog you sent me. It is now
>
>public static void RegisterBundles(BundleCollection bundles)
>        {
>            bundles.UseCdn = true; //enable CND support
>
>            //add link to jquery on the CDN (Microsoft)
>            var jqueryCdnPath = "//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"; 
> 
>            bundles.Add(new ScriptBundle("~/bundles/jquery",jqueryCdnPath).Include(
>                "~/Scripts/jQuery/jquery-{version}.js"));
>
>            jqueryCdnPath = "//ajax.aspnetcdn.com/ajax/jquery.ui/1.9.0/jquery-ui.min.js";
>            bundles.Add(new ScriptBundle("~/bundles/jqueryui", jqueryCdnPath).Include(
>                "~/Scripts/jQuery/jquery-ui-{version}.js"));
>
>            jqueryCdnPath = "//ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js";
>
>            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
>                "~/Scripts/jQuery/jquery.unobtrusive*",
>                "~/Scripts/jQuery/jquery.validate*"));
>
>            // Use the development version of Modernizr to develop with and learn from. Then, when you're
>            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
>            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
>                "~/Scripts/Shared/modernizr-*"));
>
>            bundles.Add(new ScriptBundle("~/bundles/flexigrid").Include("~/Scripts/Flexigrid/flexigrid.js"));
>
>            jqueryCdnPath = "//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js";
>            
>           bundles.Add(new ScriptBundle("~/bundles/jquery.dataTables",jqueryCdnPath).Include("~/Scripts/jQuery.DataTables/jquery.dataTables.js"));
>
>           
>
>            bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
>
>            bundles.Add(new StyleBundle("~/Content/themes/FlexiGrid/css").Include
>                ("~/Content/themes/FlexiGrid/flexigrid.css", "~/Content/css/jquery-ui-1.8.21.custom.css"));
>
>            bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
>                "~/Content/themes/base/jquery.ui.core.css",
>                "~/Content/themes/base/jquery.ui.resizable.css",
>                "~/Content/themes/base/jquery.ui.selectable.css",
>                "~/Content/themes/base/jquery.ui.accordion.css",
>                "~/Content/themes/base/jquery.ui.autocomplete.css",
>                "~/Content/themes/base/jquery.ui.button.css",
>                "~/Content/themes/base/jquery.ui.dialog.css",
>                "~/Content/themes/base/jquery.ui.slider.css",
>                "~/Content/themes/base/jquery.ui.tabs.css",
>                "~/Content/themes/base/jquery.ui.datepicker.css",
>                "~/Content/themes/base/jquery.ui.progressbar.css",
>                "~/Content/themes/base/jquery.ui.theme.css"));
>
>            BundleTable.EnableOptimizations = true;
>
>Does it make sense or I am still missing something?

Looks OK to me - but I'm only perpherally involved in this stuff. You might want to consider some client side code so that the release version will fall back to loading from your server if the CDN is unavailable. There a sample javascript implementation on the original link that I posted (http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform