我在用捆绑变压器 http://bundletransformer.codeplex.com缩小css
and 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>
正如你所看到的css
可以指定removeComments="true"
But in js
没有这样的选择。
我红色那个 YUI js 压缩器默认删除评论 https://stackoverflow.com/questions/3547976/yui-remove-javascript-comments。是的,这有点删除,但仍然留下这样的评论:
/* NUGET: BEGIN LICENSE TEXT
*
*Bla bla bla
*
* NUGET: END LICENSE TEXT */
/*!
* Bla
* Licensed under http://www.apache.org/licenses/LICENSE-2.0
*/
看起来没有办法强制 YIU js 压缩器删除注释。
https://github.com/yui/yuicompressor https://github.com/yui/yuicompressor :
以 /* 开头的 C 风格注释!被保存下来。这对于
包含版权/许可信息的评论
有什么我可以用做的吗捆绑变压器 http://bundletransformer.codeplex.com完全删除捆绑的缩小输出文件中的所有类型的注释?谷歌页面速度 https://developers.google.com/speed/pagespeed/强烈建议我这样做。
YUI 压缩器不支持删除重要注释。
我建议你安装BundleTransformer.MicrosoftAjax http://www.nuget.org/packages/BundleTransformer.MicrosoftAjax/包裹。此后注册MicrosoftAjaxCssMinifier
and MicrosoftAjaxJsMinifier
作为默认缩小器,并将以下配置设置添加到 Web.config 文件中:
<configuration>
…
<bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
…
<microsoftAjax>
<css commentMode="None" />
<js preserveImportantComments="false" />
</microsoftAjax>
…
</bundleTransformer>
…
</configuration>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)