Questions tagged [asp.net-optimization]

Questions related to the ASP.NET Microsoft.AspNet.Web.Optimization nuGet package (System.Web.Optimization namespace), which supports bundling and minification of javascript and css files.

Project homepage: https://archive.codeplex.com/?p=aspnetoptimization

The Web optimization framework is installed via NuGet at https://nuget.org/packages/Microsoft.AspNet.Web.Optimization

Description:

The ASP.NET Web optimization framework provides services to improve the performance of your ASP.NET Web applications. Current services provided by the framework include:

bundling - combining multiple scripts or style resources together into a single resource, and thereby requiring browsers to make fewer HTTP requests

minification - making scripts or styles smaller using techniques such variable name shortening, white space elimination, etc.

Additionally, the framework has multiple extensibility points, enabling you to add new services over time.

174 questions
461
votes
7 answers

How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app

I'm trying to use the new bundling feature in a project I recently converted from MVC 3 to MVC 4 beta. It requires a line of code in global.asax, BundleTable.Bundles.RegisterTemplateBundles();, which requires using System.Web.Optimization; at the…
Ian Davis
  • 19,091
  • 30
  • 85
  • 133
298
votes
16 answers

MVC4 StyleBundle not resolving images

My question is similar to this: ASP.NET MVC 4 Minification & Background Images Except that I want to stick with MVC's own bundling if I can. I'm having a brain crash trying to figure out what the correct pattern is for specifying style bundles…
Tom W Hall
  • 5,273
  • 4
  • 29
  • 35
227
votes
2 answers

Why use @Scripts.Render("~/bundles/jquery")

How does @Scripts.Render("~/bundles/jquery") differ from just referencing the script from html like this Are there any performance gains?
Tom Squires
  • 8,848
  • 12
  • 46
  • 72
202
votes
14 answers

ASP.NET Bundles how to disable minification

I have debug="true" in both my web.config(s), and I just don't want my bundles minified, but nothing I do seems to disable it. I've tried enableoptimisations=false, here is my code: //Javascript bundles.Add(new ScriptBundle("~/bundles/MainJS") …
williamsandonz
  • 15,864
  • 23
  • 100
  • 186
158
votes
3 answers

{version} wildcard in MVC4 Bundle

In MVC 4 we have bundles. While defining the bundles we can use wildcards like * for all files in a folder. In the example below what does -{version} mean? public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new…
145
votes
11 answers

ASP.NET MVC framework 4.5 CSS bundle does not work on the hosting

I am runing an App on app harbor written in MVC4. A bundle of css files doesn't work. In my local computer in debug mode I see the code of the App and I see the files. The App works as expected.
91
votes
7 answers

How can I specify an explicit ScriptBundle include order?

I'm trying out the MVC4 System.Web.Optimization 1.0 ScriptBundle feature. I have the following configuration: public class BundleConfig { public static void RegisterBundles(BundleCollection bundles) { // shared scripts …
jrummell
  • 42,637
  • 17
  • 112
  • 171
87
votes
6 answers

How to force BundleCollection to flush cached script bundles in MVC4

... or how I learned to stop worrying and just write code against completely undocumented APIs from Microsoft. Is there any actual documentation of the official System.Web.Optimization release? 'cuz I sure can't find any, there's no XML docs, and…
75
votes
15 answers

ASP.NET Bundling - Bundle not updating after included file has changed (returns 304 not modified)

I am trying out ASP.NET Bundling with ASP.NET MVC 4 application. The situation is that I want to make a CDN style service, which has JS and CSS files to which you can address from other sites with this type address:…
68
votes
20 answers

Why is my CSS bundling not working with a bin deployed MVC4 app?

I have bin deployed an MVC4 application to my hosting provider, based on advice given here and one or two on-the-fly fixes, but the most immediately apparent problem is that the bundling for css doesn't work. When I replace the bundle ref with…
ProfK
  • 49,207
  • 121
  • 399
  • 775
54
votes
3 answers

VS2012 - Web Forms - Bundling Confusion

I created a new ASP.NET Web Forms Project through Visual Studio 2012. Unfortunately, the default Site.Master file is very confusing. (I am posting these questions together because they are very related and reference the same code quite a…
Jason Parker
  • 4,960
  • 4
  • 41
  • 52
53
votes
4 answers

Bundling .js files vs CDN

In order to improve performance of our web pages, we are recommended to use CDNs to serve .js files on our web pages. That makes sense. Also, we are recommended to bundle our .js files in order to reduce the number of requests which are being made…
tugberk
  • 57,477
  • 67
  • 243
  • 335
52
votes
10 answers

MVC4 Less Bundle @import Directory

I'm trying to use MVC4 bundling to group some of my less files, but it looks like the import path I'm using is off. My directory structure is: static/ less/ mixins.less admin/ user.less In user.less, I'm attempting…
JesseBuesking
  • 6,496
  • 4
  • 44
  • 89
51
votes
2 answers

MVC4 bundling CSS failed Unexpected token, found '@import'

I'm trying to use bundling to combine & minify some CSS files. In my Global.aspx.cs Application_Start I have the following: var jsBundle = new Bundle("~/JSBundle", new JsMinify()); jsBundle.AddDirectory("~/Scripts/", "*.js", false); …
Kyle
  • 17,317
  • 32
  • 140
  • 246
44
votes
6 answers

MVC4 - Bundling does not work when optimizations are set to true

I wonder what I don't do correct here. I am using ASP.NET C# MVC4 and I want to take use of new css/js optimization feature. Here is my HTML part @Styles.Render("~/content/css") Here is my BunduleConfig.cs part bundles.Add(new…
Stan
  • 25,744
  • 53
  • 164
  • 242
1
2 3
11 12