JavaScript minification in .NET with YUI

634 views Asked by At

I'm using a BundleCollection to combine and minify my JavaScript in a .NET MVC project. I would like to use YUI Compressor to minify instead of whatever it's currently using. The code is like this, in Global.asax:

bundles.Add(new ScriptBundle("~/bundles/out").Include("~/assets/js/*.js"));

This is combining the files alright and minifying them, but I'd like it to use YUI. Thanks!

1

There are 1 answers

0
Jasen On BEST ANSWER

Do a NuGet search for YUI Compressor and you'll find packages to replace the default one.

Basically they all work the same by plugging in a new IBundleTransform implementation.

var scriptBundle = new ScriptBundle("~/bundles/js").Include("...");
scriptBundle.Transforms.Add(new YuiJsTransformer());