r.js
function (fileContents, fileName) {
            //Uglify's ast generation removes comments, so just convert to ast,
            //then back to source code to get rid of comments.
            return uglify.uglify.gen_code(uglify.parser.parse(fileContents), true);
        }
function (fileContents, fileName) {
            //Uglify's ast generation removes comments, so just convert to ast,
            //then back to source code to get rid of comments.
            return uglify.uglify.gen_code(uglify.parser.parse(fileContents), true);
        }
function ( fileContents , fileName ) { //Uglify's ast generation removes comments, so just convert to ast, //then back to source code to get rid of comments. return uglify . uglify . gen_code ( uglify . parser . parse ( fileContents ) , true ) ; }
Removes the comments from a string.

@param {String} fileContents
@param {String} fileName mostly used for informative reasons if an error.

@returns {String} a string of JS with comments removed.
Removes the comments from a string .