Javascript compression for Monorail
Last year, Hammett posted a blog entry on combining Javascript files into a single file using Monorail. I was looking to enhance the code so that it would minify Javascript and CSS files on the fly, so I took his original code and enhanced it. Alex Henderson was also looking for the same functionality, so he contributed to the patch as well. You can download it here: http://support.castleproject.org/projects/MR/issues/view/MR-ISSUE-457
The new component uses a .NET port of the Yahoo! UI Library Compressor that is available on Codeplex. The component worked great, but they did not have a strongly signed version of the library release. I made a request and they quickly turned out a release that same day, which was awesome response time.
You can now have all of your Javascript and CSS combined for you on the fly by using the component:
1: #blockcomponent(BuildJS with "key=layout")
2: $jsBuilder.Add("Content/css/main.css")
3: $jsBuilder.Add("Content/css/someOther.css")
4: $jsBuilder.Add("Content/js/prototype.js")
5: $jsBuilder.Add("Content/js/someOther.js")
6: #end
John:
This is great. When I saw Hammett’s post last year I had the exact same thought, now you’ve saved me the job. Thanks
February 10, 2009, 1:32 pmtheusualsuspect.com » Simple JS and CSS compression for MonoRail:
[...] came across a post about JavaScript compression for MonoRail. These guys have written a great patch for Hammett’s CombineJS [...]
February 11, 2009, 6:40 pmWillie:
Shoot, this is exactly what I am trying to do…with the ASP.NET MVC framework. Hopefully I can cobble together some code from each to get the job done.
April 23, 2009, 3:38 pm