Question

I've been using Combres in my applications to compress, combine and minify my javascript and css at run time. This works extremely well and satisfies YSlow perfectly.

Now I'm rethinking the whole process for performance reasons, and I'm more so thinking about doing all of this at build time instead of run time.

I'm hoping that I can get a little advice on how to do this without too much hassle. Is there an existing tool (similar to Combres) that can do what I need?

Was it helpful?

Solution 3

I originally used Chirpy to do my bundling, but have since moved over to Bundler. Bundler allows me to wire everything up nicely in a sexy build file (powershell) with relative ease. I've personally moved away from Visual Studio Build events, and started running the builds in a stand alone environment. This helps me with things like Github to Team City Continuous Integration (CI).

Here's what your build file "could" look like. (note might not fully run, this is untested)


build.ps1

# Set up varriables for build script
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$BundlerDir = "$directorypath\build_tools\bundler\"
$AppRoot = "$directorypath\SomeApp.Web\"   
$ScriptsDir = "scripts\"                                   
$CssDir = "css\"                  

# Run Bundler to Combine and Minify
&($BundlerDir + "node.exe") ( $BundlerDir + "bundler.js") ($AppRoot +$CssDir) ($AppRoot + $ScriptsDir)

# Everything else...
#    Clean the bins
#    Build the projects
#    Run the tests

OTHER TIPS

Meet Chirpy

alt text

Chirpy Mashes, minifies, and validates your javascript, stylesheet, and dotless files.

Chirpy is chippy. Use Google Closure Tools or YUI Compressor for .Net to minify and mash all of your precious assets. It's easy, it's flexible, and it's automatic.

More info here or on the CodePlex site

The MSBuild Community Tasks Project has a JSCompress task. Check out the project here: http://msbuildtasks.tigris.org/

Here's another resource on how to actually implement this task: http://www.justise.com/2007/04/20/javascript-and-css-compression-in-msbuild/

You could also take at look at ajaxtoolkit they have 2 tasks for compression of JS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top