Cassette bundles vs MVC4 bundles

bushed picture bushed · Feb 22, 2012 · Viewed 7.7k times · Source

I am currently working on a prototype ASP.NET MVC 3 solution that will be used as a base for several project rewrites (from web forms).

One of the goals that I have is to implement some script management across application as opposed to none that we currently have.

MVC 3 has a flaw IMHO: if you need specific script specified on a partial view or template view - you might end up either losing control over where script block is located in rendered HTML or having to specify every single dependent javascript file on the parent View.

I have been seriously considering using http://getcassette.net/ as a framework to resolve described issue. However, last release of MVC4 beta made me doubt myself again: MVC's Bundles look really similar to Cassette's Bundles and I am confused again:

  1. Should I implement cassette now and than migrate to MVC4 bundles?

  2. Should I implement some simplified script manager myself (sth. like Scripts helper class in MVC4 preview) and then migrate to MVC4

  3. Or should I integrate cassette into project and hope that it will be more future-proof than MVC's imlementation (I really don't like this option right now just because of sheer number of dependencies cassette comes with).

I have no experience with Cassette itself and find it really hard to make the comparison myself and would appreciate any answers or hints.

EDIT: I just figured that there is another option: installing beta nuget package for MVC bundling: https://nuget.org/packages/Microsoft.Web.Optimization

CONCLUSION: The more I look into MVC4 bundle implementation the bigger difference I notice: MVC4 bundles do not address MVC3 issue described above - they just do bundling & minification. Moreover, cassette is not just capable of rendering script tags in a specific place it is also capable of ordering them in correct order which is not trivial. So at the moment I am not satisfied with either of solutions and I will try to come up with my own minimalistic implementation hoping that situation will improve in the future.

But if you are not afraid of adding 5+ dependencies and bunch of web.config changes into your project - go for cassette. I hope it will be updated at some point to utilize MVC bundling inside to reduce functionality duplication, and hopefully, will become more modular.


UPDATE: As of version 2.0 of Cassette it is no longer necessary to include coffee script and other features of Cassette if you just need bundles and js dependency resolution. So at this point Cassette is a clear winner to me.

Answer

Robert Harvey picture Robert Harvey · Feb 22, 2012

Information about ASP.NET MVC bundling is here: http://weblogs.asp.net/scottgu/archive/2011/11/27/new-bundling-and-minification-support-asp-net-4-5-series.aspx.

ASP.NET is adding a feature that makes it easy to “bundle” or “combine” multiple CSS and JavaScript files into fewer HTTP requests. This causes the browser to request a lot fewer files and in turn reduces the time it takes to fetch them.

The next release of ASP.NET is also adding a new feature that makes it easy to reduce or “minify” the download size of the content as well.

Looks like it's essentially the same thing as Cassette. All other things being equal, use the solution that is native to ASP.NET MVC.