redsquare
redsquare

Reputation: 78667

ASP.NET MVC - Script Combine

The ASP.NET team released the script combining feature in 3.5 SP1 as detailed here http://www.asp.net/Learn/3.5-SP1/video-296.aspx. Is there a similar feature already for the MVC framework? If not, is this in scope or is it possible to somehow leverage the webforms capability in MVC? I see this site uses a custom jquery.package.master which, I assume, they have rolled themselves (maybe into the build cycle, however it is not all minified therefore I think they have manually appended the scripts together rather than some automated minify & combine task). Would be interested in any ideas how to accomplish this in MVC but I dont want to begin rolling any of my own functionality in case I will be duplicating work in progress.

Upvotes: 14

Views: 2288

Answers (3)

Mangesh
Mangesh

Reputation: 3997

Every day there is a different way of doing things and the techniques changes.

At this time there is a very good Nuget Package released in CodePlex.

Combres - WebForm & MVC Client-side Resource Combine Library
http://combres.codeplex.com/

http://weblogs.asp.net/gunnarpeipman/archive/2009/07/04/asp-net-mvc-how-to-combine-scripts-and-other-resources.aspx

Upvotes: 2

Chris Brandsma
Chris Brandsma

Reputation: 11736

Another option is in the Telerik Native UI Extensions for MVC (free library and open source), called ScriptRegistar. It will combine and compress javascript for you, and is fairly feature rich. There is also a class for doing the same to css as well.

I am using this to combine +20 javascript files into one file which is downloaded by the browser.

http://www.telerik.com/products/aspnet-mvc.aspx and you can get it via NuGet.

Upvotes: 3

Jeff Sheldon
Jeff Sheldon

Reputation: 2094

Here's what I do, in case it's helpful.

In my postbuild I call a command line version of Dean Edwards's Packer. It combines the scripts and packs them for me.

For now though, I keep all of my stuff seperate and use a Helper method to include my scripts, and if the debug flag is not present it will include the packed versions, otherwise it includes the unpacked.

Upvotes: 7

Related Questions