admin管理员组文章数量:1418680
In my javascript I have some bits of code specifically used for debugging which I don't want to include in the live site. Is there a way I can semi-ment these bits of code so that they run as javascript normally, but that yui pressor thinks they're ments and removes them?
For example
for(key in modules) {
try {
MyApp[key].init(modules[key].params);
} catch (e) {
console.log("Module " + key + " threw an error");
break;
}
}
I would like to be able to ment out the console.log bit automatically when pressing to deploy to the live site. So maybe wrap the code in something like
//yuiIgnore
console.log("Module " + key + " threw an error");
//endyuiIgnore
In my javascript I have some bits of code specifically used for debugging which I don't want to include in the live site. Is there a way I can semi-ment these bits of code so that they run as javascript normally, but that yui pressor thinks they're ments and removes them?
For example
for(key in modules) {
try {
MyApp[key].init(modules[key].params);
} catch (e) {
console.log("Module " + key + " threw an error");
break;
}
}
I would like to be able to ment out the console.log bit automatically when pressing to deploy to the live site. So maybe wrap the code in something like
//yuiIgnore
console.log("Module " + key + " threw an error");
//endyuiIgnore
Share
Improve this question
edited Sep 27, 2010 at 10:09
wheresrhys
asked May 13, 2010 at 10:30
wheresrhyswheresrhys
23.6k21 gold badges97 silver badges165 bronze badges
1
- Can you please provide a sample of the code you're trying to minify BUT is not getting stripped out. Secondly, can you please provide the mand line you run to minify or the configuration settings (if you're using the .NET port). – Pure.Krome Commented Sep 24, 2010 at 12:23
1 Answer
Reset to default 8With regard specifically to console.log
statements:
I'm using sed
to replace "console"
with "//console"
before launching the pressor:
sed -e "s/console/\/\/console/g" originalWithConsoleStatements.js > noConsoleStatements.js
This statement sits inside a shell script which then launches the pressor.
本文标签: javascriptTelling YUI compressor to remove specific noncommented codeStack Overflow
版权声明:本文标题:javascript - Telling YUI compressor to remove specific non-commented code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745294210a2651977.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论