Question: What is the best way to remove asserts (`console.assert`) from JavaScript code for production version? Maybe there is some software that can be configured to sort of build JavaScript and remove asserts?

**UPDATE *\_*\_\_*\_*\_\_*\_*\_\_*\_*\_\_*\_*\_\_*\_*\_\_*\_*\_\_*\_*\_\_*\_*\_**

I've installed GRUNT and groundskeeper plugin. This is what my Gruntfile.js has:

```
module.exports = function(grunt) {
    // Project configuration.
    grunt.initConfig({
    groundskeeper: {
        compile: {
            files: {
              'calculator/add.js': 'calculator/add.js'
            },
            options: {
                console: false
            }
        }
    }
});

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-groundskeeper');

```

The problem is with when I run `grunt groundskeeper` I get the following error:

```
Running "groundskeeper:compile" (groundskeeper) task
Warning: Line 2: Invalid left-hand side in assignment Use --force to continue.

```

I assume that the problem is with this line:

```
'calculator/add.js': 'calculator/add.js'

```

Since if I replace it with the following:

```
'path/to/result.js': 'path/to/source.js'

```

Everything works fine:

```
Running "groundskeeper:compile" (groundskeeper) task
>> File path/to/result.js created empty, because its counterpart was empty.
>> 1 files read, 0 cleaned.

```

What's wrong with the my original line?

Answer: 
I am using the grunt-groundkeeper plugin for this:  

<https://github.com/Couto/grunt-groundskeeper>

If you're not using [Grunt](http://gruntjs.com/getting-started) yet, I really recommend using it for JavaScript projects. Explaining how to use Grunt itself is out of scope of this question.

The following example config sets removing all logging statements in the `www/scripts.min.js` file as the default task.

```
'use strict';

module.exports = function(grunt) {

    grunt.initConfig({
        groundskeeper: {
            dist: {
                files: {
                    'www/scripts.min.js': 'www/scripts.min.js'
                }
            }
        });

    grunt.loadNpmTasks('grunt-groundskeeper');

    grunt.registerTask('default', ['groundskeeper']);
};

```
make assert as an empty function in your production

```
console.assert = function(){}

```

if you can check it is a production version then put the code like,

```
if (production) {
   console.assert = function(){}
}

```

for old IE shim

```
  if (typeof console == "undefined" || typeof console.assert == "undefined"){
       var console = { assert : function() {} }; 
    }

```