Concatenate and minify JavaScript on the fly OR at build time - ASP.NET MVC

后端 未结 8 2404
日久生厌
日久生厌 2020-11-29 15:38

As an extension to this question here Linking JavaScript Libraries in User Controls I was after some examples of how people are concatenating and minifying JavaScript on the

8条回答
  •  星月不相逢
    2020-11-29 15:59

    Rejuicer is a great new minifier for ASP.NET that's getting a lot of buzz: http://rejuice.me

    It is configured as a HTTP module & performs minification at run-time (once) and caches the output.

    It:

    • Has a fluent interface for configuration
    • Allows you to specify files to minify with wildcard rules
    • Runs on Windows Azure
    • Somewhat magically turns itself off in development environments, so you can debug your original javascript code (not minified).

    The configuration (done on ApplicationStart in global.asax.cs) is as simple as:

    OnRequest.ForJs("~/Combined.js")
                .Compact
                .FilesIn("~/Scripts/")
                  .Matching("*.js")
                .Cache
                .Configure();
    

提交回复
热议问题