寻找从大量的javascript文件中删除评论 [英] Looking to remove comments from a large amount of javascript files

查看:97
本文介绍了寻找从大量的javascript文件中删除评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的dilemna:

Here is my dilemna:

我是一个noob(目前实习,帮助维护两个电子商务网站)在javascript。我最近被分配删除在我们的javascript库中发生的所有意见(这是超过25,000评论!)。显然,我想找一个函数或一些预先存在的程序,可以解析通过代码,删除所有字符后面//或* / ...

I am a noob (currently interning and helping to maintain two e-commerce sites) at javascript. I was recently assigned to remove all the comments that occur in our javascript libraries (which is over 25,000 comments!). Obviously I want to find a function or some pre-existing program that can parse through the code, removing all characters following // or */...

例如Yui,jscompressor.com和uglifyJS,这将使这个任务更自动化,但有一些问题。它们或者太过激进(缩短变量名称,删除所有空格等),或者它们要求一次输入一行或一个文件。我正在处理的是千年的.js文件。

I have looked into some minifiers available online such as Yui, jscompressor.com, and uglifyJS that would make this task more automated, but there are a few problems. Either they are too aggressive (shortening variable names, removing all whitespace, etc.) or they require that you feed one line or one file at a time. I am dealing with literally 1000s of .js files.

其他细节:我们的开发环境是Eclipse IDE和xammp;语言是html,php,css。

Additional details: our development environment is Eclipse IDE and xammp; languages are html, php, css.

程序的任何建议都可以满足我的需求,这将是巨大的!

Any recommendations of a program that can fit my needs would be great!

推荐答案

仔细观察uglifyjs。它既不压缩也不是默认的(你必须分别给出-c和-m选项),你可以精细地选择什么类型的压缩,甚至到指定正则表达式的水平为什么类型评论删除。而且,如果你这么倾向,你甚至可以在出路的时候打印。那么使用它的问题是什么?

Take a closer look at uglifyjs. It neither compresses nor munges by default (you have to give the -c and -m options, respectively), and you can choose in fine detail what kinds of compression it does, even to the level of specifying a regular expression for what kinds of comments to remove. And, you can even pretty print on the way out, if you're so inclined. So what's the problem with using it?

这篇关于寻找从大量的javascript文件中删除评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆