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

后端 未结 8 2378
日久生厌
日久生厌 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 16:08

    Here's what I've used for concatenating, compressing and caching CSS and JS files: http://gist.github.com/130913

    It just requires Yahoo.Yui.Compressor.dll in the bin directory. It doesn't compress at compile time, but the files are cached with a file dependency, so they are only loaded once, until they're changed.

    Then I just add this code in the :

    
    

    and this just before the :

    
    

    It's designed to work with multiple files all in the same path but could easily be upgraded to support different paths.

提交回复
热议问题