Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassette bundles vs MVC4 bundles

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.

like image 682
bushed Avatar asked Feb 22 '12 17:02

bushed


People also ask

What is difference between bundling and minification?

Both bundling and minification are the two separate techniques to reduce the load time. The bundling reduces the number of requests to the Server, while the minification reduces the size of the requested assets.

What are the different ways for bundling and minification in asp net core?

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.

How does bundling increase performance in MVC?

To improve the performance of the application, ASP.NET MVC provides inbuilt feature to bundle multiple files into a single, file which in turn improves the page load performance because of fewer HTTP requests.

What is the use of BundleConfig in MVC?

Bundling and minification techniques were introduced in MVC 4 to improve request load time. Bundling allows us to load the bunch of static files from the server in a single HTTP request. In the above figure, the browser sends two separate requests to load two different JavaScript file MyJavaScriptFile-1.


2 Answers

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.

like image 71
Robert Harvey Avatar answered Sep 23 '22 08:09

Robert Harvey


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.

like image 33
Shea Daniels Avatar answered Sep 26 '22 08:09

Shea Daniels