Skip to content

Instantly share code, notes, and snippets.

@guileen
Created April 25, 2011 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guileen/940293 to your computer and use it in GitHub Desktop.
Save guileen/940293 to your computer and use it in GitHub Desktop.
Dead code removal of closure compiler and uglifyjs
(function(){
var DEBUG=false,
NEVER_READ='hello';
(function() {
if(DEBUG){
console.log('Hello world');
}
})();
function a() {
if(DEBUG){
console.log('Hello world');
}
}
function b() {
}
function c(){
}
function d(){
}
function e(){
}
function f(){
}
function g(){
console.log('g');
}
a();
})();
(function(){
console.log('a');
console.log('b');
console.log('c');
g();
})()
@guileen
Copy link
Author

guileen commented Apr 25, 2011

uglifyjs

(function(){function i(){console.log("g")}function h(){}function g(){}function f(){}function e(){}function d(){}function c(){a&&console.log("Hello world")}var a=!1,b="hello";(function(){a&&console.log("Hello world")})(),c()})()(function(){console.log("a"),console.log("b"),console.log("c"),g()})()

@guileen
Copy link
Author

guileen commented Apr 25, 2011

closure-compiler ADVANCED

console.log("a");console.log("b");console.log("c");g()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment