Last active
January 30, 2023 01:33
-
-
Save elijahmanor/7884984 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Avoid `console` errors in browsers that lack a console. | |
(function() { | |
var method; | |
var noop = function () {}; | |
var methods = [ | |
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', | |
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', | |
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', | |
'timeStamp', 'trace', 'warn' | |
]; | |
var length = methods.length; | |
var console = (window.console = window.console || {}); | |
while (length--) { | |
method = methods[length]; | |
// Only stub undefined methods. | |
if (!console[method]) { | |
console[method] = noop; | |
} | |
} | |
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( etm, undefined ) { | |
var myVariable = 0; | |
etm.init = function() { | |
myVariable += 1; | |
}; | |
function secret() { | |
myVariable += 2; | |
}; | |
}( window.etm = window.etm || {} )); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( etm, undefined ) { | |
var myVariable = 0; | |
console.log( "test 1" ); | |
etm.init = function() { | |
console.log( "test 2" ); | |
myVariable += 1; | |
}; | |
function secret() { | |
console.log( "test 3" ); | |
myVariable += 2; | |
}; | |
}( window.etm = window.etm || {} )); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function( grunt ) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON( "package.json" ), | |
removelogging: { | |
dist: { | |
src: "src/<%= pkg.name %>.js", | |
dest: "build/<%= pkg.name %>.clean.js", | |
options: {} | |
} | |
} | |
}); | |
grunt.loadNpmTasks( "grunt-remove-logging" ); | |
grunt.registerTask( "default", ["removelogging"] ); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
debug.log( "test" ); // Level 1 | |
debug.debug({ msg: "test" }); // Level 2 | |
debug.info( false ); // Level 3 | |
debug.warn( 42 ); // Level 4 | |
debug.error( [1, 2, 3] ); // Level 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Uglify | |
uglifyjs --define DEBUG=false "hello.js" > "hello.min.js" | |
# Uglify2 | |
uglifyjs --compress --define DEBUG=false hello.js -o hello.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( typeof DEBUG === "undefined" ) DEBUG = true; | |
function sayHello() { | |
DEBUG && console.log( "Hello World!" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment