sre*_*moh 5 javascript yui-compressor bundling-and-minification bundletransformer asp.net-mvc-5
我正在使用BundleTransformer缩小css和js资源
<yui>
<css compressionType="Standard" removeComments="true" lineBreakPosition="-1" />
<js compressionType="Standard" obfuscateJavascript="true" preserveAllSemicolons="false" disableOptimizations="false" ignoreEval="false" severity="0" lineBreakPosition="-1" encoding="UTF8" threadCulture="en-us" />
</yui>
Run Code Online (Sandbox Code Playgroud)
正如你所看到的那样css可以指定removeComments="true"
但是js没有这样的选择.
我认为YUI js压缩器默认删除注释.是的,有点删除,但它仍然留下这样的评论:
/* NUGET: BEGIN LICENSE TEXT
*
*Bla bla bla
*
* NUGET: END LICENSE TEXT */
/*!
* Bla
* Licensed under http://www.apache.org/licenses/LICENSE-2.0
*/
Run Code Online (Sandbox Code Playgroud)
看起来没有办法强迫YIU js minifier删除评论.
https://github.com/yui/yuicompressor:
以/*开头的C风格评论!保存完好.这对包含版权/许可证信息的评论很有用
有没有什么我可以通过使用BundleTransformer完全删除捆绑的缩小输出文件中的所有类型的注释?谷歌页面速度强烈建议我这样做.
YUI 压缩器不支持删除重要注释。
\n\n我建议您安装BundleTransformer.MicrosoftAjax包。此后将MicrosoftAjaxCssMinifier和注册MicrosoftAjaxJsMinifier为默认缩小器,并将以下配置设置添加到 Web.config 文件中:
<configuration>\n \xe2\x80\xa6\n <bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">\n \xe2\x80\xa6\n <microsoftAjax>\n <css commentMode="None" />\n <js preserveImportantComments="false" />\n </microsoftAjax>\n \xe2\x80\xa6\n </bundleTransformer>\n \xe2\x80\xa6\n</configuration>\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1890 次 |
| 最近记录: |