Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When using the ASP.NET Script Bundles, you can provide the CDN locations where your script library can be found. When you also add the code locally you get the benefit of being able to debug against the non-minified version while the CDN version will be used when the site runs in production.</p> <p>See the <a href="http://blogs.msdn.com/b/rickandy/archive/2012/08/14/adding-bundling-and-minification-to-web-forms.aspx" rel="nofollow">following documentation on setting up script bundles on ASP.NET Web Forms</a>.</p> <p>basically you need to add a couple of lines to the Global.asax:</p> <pre><code>void Application_Start(object sender, EventArgs e) { BundleConfig.RegisterBundles(BundleTable.Bundles); } </code></pre> <p>And then create your bundle as follows:</p> <pre><code>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. } </code></pre> <p>And reference it like this:</p> <pre><code>&lt;asp:PlaceHolder runat="server"&gt; &lt;%: Scripts.Render("~/bundles/modernizr") %&gt; &lt;%: Scripts.Render("~/bundles/jquery") %&gt; &lt;%: Scripts.Render("~/bundles/jqueryui") %&gt; &lt;/asp:PlaceHolder&gt; </code></pre> <p>This should please both the browser <em>and</em> the editor.</p> <hr> <p>You can also configure the <code>&lt;scriptmanager&gt;</code> to automatically fall back to the CDN using the following pieces of code:</p> <pre><code>&lt;asp:ScriptManager runat="server" EnableCdn="true"&gt; &lt;Scripts&gt; &lt;asp:ScriptReference Name="jquery" /&gt; &lt;asp:ScriptReference Name="jquery.ui.combined" /&gt; &lt;/Scripts&gt; &lt;/asp:ScriptManager&gt; </code></pre> <p>And this configuration:</p> <pre><code>var mapping = ScriptManager.ScriptResourceMapping; // Map jquery definition to the Google CDN mapping.AddDefinition("jquery", new ScriptResourceDefinition { Path = "~/Scripts/jquery-2.0.0.min.js", DebugPath = "~/Scripts/jquery-2.0.0.js", CdnPath = "http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", CdnDebugPath = "https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.js", CdnSupportsSecureConnection = true, LoadSuccessExpression = "window.jQuery" }); // Map jquery ui definition to the Google CDN mapping.AddDefinition("jquery.ui.combined", new ScriptResourceDefinition { Path = "~/Scripts/jquery-ui-1.10.2.min.js", DebugPath = "~/Scripts/jquery-ui-1.10.2.js", CdnPath = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js", CdnDebugPath = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.js", CdnSupportsSecureConnection = true, LoadSuccessExpression = "window.jQuery &amp;&amp; window.jQuery.ui &amp;&amp; window.jQuery.ui.version === '1.10.2'" }); </code></pre> <p>Read the following blog by <a href="http://www.hanselman.com/blog/CDNsFailButYourScriptsDontHaveToFallbackFromCDNToLocalJQuery.aspx" rel="nofollow">Scott Hanselman for more details</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload