1

in particular for Google Closure and Uglify.

Uglify uses 32K lines

https://github.com/mishoo/UglifyJS

while Google uses about 500 lines.

https://developers.google.com/closure/compiler/faq#linefeeds

One of them seem to be addressing a ghost issue.

Why such a difference? What are the true considerations regarding maximum length?

2 Answers2

4

From the Closure Compiler docs:

Why are there random line feeds in compiled scripts?

The Closure Compiler intentionally adds line breaks every 500 characters or so. Firewalls and proxies sometimes corrupt or ignore large JavaScript files with very long lines. Adding line breaks every 500 characters prevents this problem. Removing the line breaks has no effect on a script's semantics. The impact on code size is small, and the Compiler optimizes line break placement so that the code size penalty is even smaller when files are gzipped.

Community
  • 1
  • 1
cmbuckley
  • 40,217
  • 9
  • 77
  • 91
0

Sometimes, when you concatenate various files and then optimize + minify them with Google Closure, seemingly random new lines are inserted.

Most likely to indicate the separation between the different files like @ArrayKnight said.

EDIT: You can clearly see in the Google source code that the different files were wrapped in auto-executing anonymous function like this :

(function() {
    // Minified module file here
})();
m_vdbeek
  • 3,704
  • 7
  • 46
  • 77