I am trying to use a CDN for loading jquery. I have read this article and this seems like it should be very straightforward.
My script bundle is defined as follows.
bundles.UseCdn = true; bundles.Add(new ScriptBundle("~/bundles/jquery", "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js").Include( "~/Scripts/jquery-{version}.js"));
I am including it on the page as follows:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <title>@ViewBag.Title</title> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") </head> <body> @RenderBody() @Scripts.Render("~/bundles/jquery") @RenderSection("scripts", required: false) </body> </html>
But when I look at firebug it seems that jquery is being loaded from localhost.
I have tried with both realease and debug builds. What am I missing? I think this should be quite straightforward. Thanks.
The optimization package in ASP.NET MVC framework has built-in support for Content Delivery Network (CDN). Using CDN can improve the performance of your application. The trick is to use it for popular libraries where the chances are that those libraries may have been cached by user's browser.
Bundling and Minification are two performance improvement techniques that improves the request load time of the application. Most of the current major browsers limit the number of simultaneous connections per hostname to six. It means that at a time, all the additional requests will be queued by the browser.
The ScriptBundle class represents a bundle that does JavaScript minification and bundling. You can create style or script bundles in BundleConfig class under App_Start folder in an ASP.NET MVC project.
Run your application in debug="false"
mode or use BundleTable.EnableOptimizations = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With