Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

I ended up using Cassette on my last project and it's working pretty well. There's really not a whole lot of configuration to it if you use NuGet, so my thinking is that it wouldn't be too hard to use Cassette now and then switch later if you wanted to.

One other thing to consider is that Cassette does Less compiling. I'm not sure if the MVC4 bundling does that or not since I haven't had time to read up on it.

Cassette is still an interesting alternative as it has native support for less and coffescript. It has also support for HTML Templates, if you are interested in client side mvc frameworks (backbone, knockout etc)

Just as an update to this, LESS and CoffeeScript support was added in the Update 2 package for Visual Studio 2012, so it's starting to look more and more like it would be better to add what transformations you need to the native implementation of the Bundling/Minification backed into MVC4 than go with Cassette in the long term.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top