Why do we have newlines in minified JavaScript?

后端 未结 3 1358
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 00:30

I know about a similar question but it is a tiny bit off from what I am asking here, so please don\'t flag it as a duplicate.

When you

3条回答
  •  猫巷女王i
    2020-12-06 00:46

    To cite the Closure Compiler FAQ:

    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.

    This is relevant to any minification programs in general.

提交回复
热议问题