Sam Jones
Sam Jones

Reputation: 4618

adding a URL to a Microsoft.Web.Optimization bundle

Is it possible to add a url from another domain to the bundling in Microsoft.Web.Optimization?

I want to add a reference to replace the following link:

<link href='http://fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700' rel='stylesheet' type='text/css'>

My code for creating a css bundle which works with local files is as below:

Bundle cssCommon = new Bundle("~/cssCommon", typeof(CssMinify));
cssCommon.AddDirectory("~/content/", "aom.common.*", false);
BundleTable.Bundles.Add(cssCommon);

Upvotes: 0

Views: 149

Answers (2)

Code Uniquely
Code Uniquely

Reputation: 6373

Actually leaving that content on the other host is probably a better thing to do.

  • You benefit from the Google's global distribution potentially this means that the font may be 'closer' on the internet and have less lag than your actual web server.
  • You can download the content in parallel with your main content (each host is a separate set of downloads threads so it won't block your existing content or add to the total transfer time of that content)
  • You benefit from Google's server resilience and up time.

The end user real world experience may actually be better as a result.

Upvotes: 1

Joe Ratzer
Joe Ratzer

Reputation: 18549

That doesn't really make sense because bundling reduces the number of requests from the website's server. Referencing goodleapis is obviously on another server.

There is the concept of CDNs though, and these can be changed depending on the release, this link has some useful information on using a CDN with Bundling and Minification.

Upvotes: 0

Related Questions