Why does Google's Closure Compiler leave a few unnecessary spaces or line breaks?

Posted by Bungle on Stack Overflow See other posts from Stack Overflow or by Bungle
Published on 2010-06-10T20:05:36Z Indexed on 2010/06/10 23:22 UTC
Read the original article Hit count: 403

I've noticed that every time I use Google's Closure Compiler Service, it leaves a few unnecessary spaces in the compiled code presented on the right-hand side of the page. These correspond to line breaks in the hosted version of the compiled code.

For example (note the line breaks, each of which seems unnecessary):

http://troy.onespot.com/static/stack_overflow/closure_spaces.js

To date, I've just been removing them manually, but I'm curious why they're there. Is it to limit the line length of the hosted version of the code to make it more readable? Could the compiler be smart enough to leave or insert those intentionally to maximize GZIP compression efforts?

I know that they have a trivial effect on the file size, but with so much effort going into minifying every last byte in the source script, it's counterintuitive why they're there.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about minifier