1

I know I have seen an article this somewhere (specifically related to Azure too!) but I forgot to bookmark it (doh!) and after hours searching can't find it anywhere :(

I have a MVC Application running in Azure with multiple layout pages and roughly 20+ javascript files (each quite lengthy hence why they are seperate!).

Each layout page includes a couple of script and css files, the rest are added using @head { } (razor syntax for adding sections to the layout page outside of the body.

I cannot remember if the article was exactly what I was after but what I would like to do is combine AND minify the nessessary javascript and css files at runtime dependant on the layout and page.

For example if i had a layout file with:

<script src="script1.js"></script>
<script src="script2.js"></script>
<link href="css1.css" />

and a page with

<script src="pagespecificscript.js"></script>
<script src="usercontrolspecificscript.js"></script>
<link href="page.css" />

I would want a 2 minified files to be sent to the user's browser such as

<script src="201101010800abc-min.js"></script>
<link href="201101010800abc-min.css" />

Thanks in advance!

Jamie
  • 4,670
  • 5
  • 35
  • 49
  • Check out this question http://stackoverflow.com/questions/6738117/strategy-for-javascript-files-on-azure – Ivo Oct 04 '11 at 10:12

1 Answers1

3

Check out RequestReduce. Its a project I have been working on that minifies/merges css and optimizes and sprites images. It does this on the fly with no code changes and very little confg necessary. Next week, I will be releasing javascript merge/minify. I have been blogging quite a bit about this lately (http://www.mattwrock.com/post/2011/09/10/Adopt-RequestReduce-and-see-immediate-Yslow-and-Google-Page-Speed-score-improvements-not-to-mention-a-faster-site!.aspx) so it is possible that this is the article that you had run into. The easiest way to grab RequestReduce is via nuget: Install-Package RequestReduce.

I'm a dev lead on a couple Microsoft web sites where we have been deploying this with good success, so it is enterprise tested and quite scalable. However it is not a Microsoft product but rather a personal OSS project I have been contributing to. Its also free.

Matt Wrock
  • 6,590
  • 29
  • 23
  • Hi Matt, That looks very interesting especialy the success of using it with Visual Studio Gallery - i'll try it out later today and look forward to trying out the Javascript version next week. Out of interest are you using a custom or open source minification for the Javascript? The CSS spriting tool also looks fantastic - having multiple copies of editable,optimised files and sprites seemed to be a necessary evil but this means a lot less pain when editing images. – Jamie Oct 04 '11 at 11:20
  • Hi Matt, I can't seem to get RequestReduce to run nor on IIS or on Azure. The module shows up fine in IIS manager but does nothing to js or css files - like it's not even running. – Jamie Oct 16 '11 at 20:02
  • Jamie, can you open an issue on my github site? I'd like to see the web config if you could share it and a link to your site if it is accesible. Did it create a folder called "RequestReduceContent" in your site's root? I really want to get this working for you and make sure there is not a bug preventing it from running it other environments as well. The issues url is https://github.com/mwrock/RequestReduce/issues and if you could include details like if you are running in medium or full trust and also if the account under which w3wp.exe runs has write access to your app root. Thanks! – Matt Wrock Oct 17 '11 at 01:51