This buged me also because I wanted to optimize web page for CEO purposes, and I was using three.js which is huge file. I tried to minimized but still there was to much console statements in file.
So I created python script which replaces all console statements with 0.
It was tested on three.js and its working like a charm.
- 617,8kB three.js.min
- 580,3kB new.three.js.min
Here is a gist...
https://gist.github.com/urosjarc/aa531af1f18c804a8dd8953190c2bef7
Here is example output...
▶ python3 rm_console_statements.py
Enter input js file: three.min.js
Number of consoles: 424
Removed: console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)
Removed: console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.")
Removed: console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.")
Removed: console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().")
Removed: console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")
Removed: console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t)
Removed: console.warn("THREE.Texture: Unable to serialize Texture.")
Removed: console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.")
Removed: console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.")
Removed: console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().")
Removed: console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead.")
Removed: console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)
Removed: console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.")
Removed: console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.")
Removed: console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.")
Removed: console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.")
Removed: console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.")
Removed: console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.")
Removed: console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().")
Removed: console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")
Removed: console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.")
Removed: console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.")
Removed: console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.")
Removed: console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)
Removed: console.error("THREE.Object3D.add: object can't be added as a child of itself.",t)
Removed: console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t)
Removed: console.warn("THREE.Material: '"+e+"' parameter is undefined.")
Removed: console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")
Removed: console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")
Removed: console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")
Removed: console.warn("THREE.Color: Unknown color "+t)
Removed: console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i)
Removed: console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i)
Removed: console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i)
Removed: console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i)