I have an @import statement in one of my css files... all my css files are bundled/minified, and apparently that is not kosher as I get an error:
run-time error CSS1019: Unexpected token, found '@import'
The import is a font from Google. What is the proper way to handle CDN in MVC4?
thanks
Bundling and minification are two techniques you can use in ASP.NET to improve page load performance for your web application. Bundling combines multiple files into a single file. Minification performs a variety of different code optimizations to scripts and CSS, which results in smaller payloads.
Bundling and minification is enabled or disabled by setting the value of the debug attribute in the compilation Element in the Web. config file. In the following XML, debug is set to true so bundling and minification is disabled. To enable bundling and minification, set the debug value to "false".
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.
This was embarrassingly simple...
In BundleConfig.cs :
bundles.UseCdn = true;
// bundles code
var cdnPath = "path to your resource (font in my case)";
bundles.Add(new StyleBundle("~/fonts", cdnPath));
Then in layout
@Styles.Render("~/fonts")
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