Comment Removal
/** * @fileoverview Module authoring format. */ var define = function() { // some comment var reg = /.*/g; // comment */ } /* ok, I will disappear. */ var s = '// i am string'; require('xx'); var t = 'i am string too'; // require('zz'); /* will not // be removed */ var xx = 'a'; // // var Calendar = require('calendar'); var str = " /* not a real comment */ "; var regex = /\/*.*/; var z = '"\''; var r = /\/*/require('mod')/**/; var a = / \/\/ \/b\//g; // 不用考虑下面这个极端情况 var a=/ // /b\//g;
Remove Comments
References
Removing comments in JavaScript
DEMO
https://github.com/seajs/seajs/issues/478
http://jsperf.com/remove-comments
http://stackoverflow.com/questions/3577767/javascript-comment-stripper