14

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.

2
  • Whoever marked this down please dont stay silent and tell the community why:) I would love to hear your issue with it. Commented Nov 20, 2008 at 11:11
  • I'm afraid some folks are just punks, sadly. It's a good question. Commented Nov 18, 2010 at 16:42

3 Answers 3

7

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.

Sign up to request clarification or add additional context in comments.

3 Comments

not sure I'd pack them but its a good idea (packers can cause issues) and its better to use min + gzip. If you start to gzip a packed file it ends up bigger much like a zip of a zip. Anyway I am now useing YUI as part of my TeamCity build process. You were on the right track.
@redsquare: Good point. Perhaps Jeff is interested in code obfuscation as well as minimizing file size.
You're correct Roy that is/was the purpose. But I've learned smarter techniques in the past 3 or so years since this question was asked. :)
3

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.

1 Comment

yeah its what I use now - this was not available when i wrote this post many moons ago!
2

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

1 Comment

When I added Combres to my project (via NuGet) I found that it monkeyed with my web.config a little too much. It uses log4net (which I am already using), and it added an incorrect additional log4net section, as well as a logger that I didn't want. Something to watch out for before committing the Combres code changes to your vcs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.