lautis / uglifier

Ruby wrapper for UglifyJS JavaScript compressor.
http://www.rubydoc.info/gems/uglifier
MIT License
613 stars 82 forks source link

Weird output #82

Closed jcuenod closed 9 years ago

jcuenod commented 9 years ago

At the end of my uglified js on heroku, I have:

/* ... actual code */}.call(this),function(){}.call(this),function(){}.call(this),function(){}.call(this),function(){}.call(this),function(){}.call(this);

I must be honest, I'm not sure how to begin debugging this.

lautis commented 9 years ago

Are the empty IIFEs present also in non-uglified JS? My first guess would be that there are CoffeeScript files that are empty or only has Sprockets requires.

jcuenod commented 9 years ago

There are some but surely this is not useful behaviour?

lautis commented 9 years ago

CoffeeScript wraps all files to a function that is invoked immediately. This prevents variable declarations from multiple files from interfering with each other when the files are concatenated (which is what Rails asset pipeline is doing). Sure, those empty functions could be removed in minification process, but UglifyJS isn't currently able to perform such optimisation.

jcuenod commented 9 years ago

Okay, so the solution is delete empty (auto-generated) files?

lautis commented 9 years ago

Yes, that should at least remove some of the functions. They don't really hurt you much anyway. Repetitive code should compress well.