compile WHITESPACE_ONLY -> wants to load deps.js

433 views
Skip to first unread message

ghost23

unread,
Sep 8, 2011, 10:21:17 AM9/8/11
to Closure Compiler Discuss
hello,

i compile my scripts with the closure builder and compiler, using the
WHITESPACE_ONLY option.
Why is it though, that the resulting .js still wants to load a
deps.js? I thought, that everything would be
included in one file, if i compile?

This is my build:

<target name="google-closure-compile">
<exec executable="C:\Python27\python.exe">
<arg value="build/bin/closurebuilder.py"/>
<arg value="--root=libs/google-closure/"/>
<arg value="--root=libs/third-party/"/>
<arg value="--root=libs/soyutils/"/>
<arg value="--root=src/"/>
<arg value="--root=src-soy/"/>
<arg value="--output_mode=compiled"/>
<arg value="--compiler_jar=build/bin/compiler.jar"/>
<arg value="--namespace=${namespace}"/>
<arg value="--compiler_flags=--compilation_level=WHITESPACE_ONLY"/>
<arg value="--output_file=bin/js/bc.js"/>
</exec>
</target>

John Lenz

unread,
Sep 8, 2011, 11:15:49 AM9/8/11
to closure-comp...@googlegroups.com
Because, "white space only" only removes whitespace it doesn't do anything else do the code is exactly the same as the uncompiled version (only without whitespace and concatenated together).  You likely want to use "SIMPLE_OPTIMIZATIONS" instead.

ghost23

unread,
Sep 9, 2011, 3:59:16 AM9/9/11
to Closure Compiler Discuss
OK. But if it is concatenating everything into one file, wouldn't it
make
sense to disable the loading of additional js files? I mean, if
everything is
included anyway, why loading the same stuff as single files again?

Perhaps this could be changed?!

Nick Santos

unread,
Sep 9, 2011, 9:34:02 AM9/9/11
to closure-comp...@googlegroups.com
On Fri, Sep 9, 2011 at 3:59 AM, ghost23 <sven....@googlemail.com> wrote:
> OK. But if it is concatenating everything into one file, wouldn't it
> make
> sense to disable the loading of additional js files? I mean, if
> everything is
> included anyway, why loading the same stuff as single files again?
>
> Perhaps this could be changed?!

how would Closure Library know that the files were concatenated together?

i believe you can disable deps loading by just setting
window.CLOSURE_NO_DEPS = true;
before loading the script file.

ghost23

unread,
Sep 12, 2011, 3:30:38 AM9/12/11
to Closure Compiler Discuss
Hi Nick,

well, how does it know in "SIMPLE_OPTIMIZATIONS" mode? I assume, the
compiler
sets some attribute/property so that the library knows, like the one
that
you are suggesting. Thanks for the tip, by the way, will try that.

On Sep 9, 3:34 pm, Nick Santos <nicksan...@google.com> wrote:

Nick Santos

unread,
Sep 12, 2011, 9:31:59 AM9/12/11
to closure-comp...@googlegroups.com
Closure-Library uses @defines to do this. See:
http://code.google.com/closure/compiler/docs/js-for-compiler.html

@defines are not changed under WHITESPACE_ONLY mode, because then it
would not be whitespace-only.

ghost23

unread,
Sep 12, 2011, 9:48:25 AM9/12/11
to Closure Compiler Discuss
I see. So perhaps i don't understand the usecase for WHITESPACE_ONLY,
then.
What is the usecase for loading a concatenated/whitespace-less version
of my code PLUS the original code?
Which version does actually make it into the runtime?

Tim Wintle

unread,
Sep 12, 2011, 10:58:43 AM9/12/11
to closure-comp...@googlegroups.com
On Mon, 2011-09-12 at 06:48 -0700, ghost23 wrote:
> I see. So perhaps i don't understand the usecase for WHITESPACE_ONLY,
> then.
> What is the usecase for loading a concatenated/whitespace-less version
> of my code PLUS the original code?

If you didn't want any compilation / variable renaming etc - but you did
want to reduce the filesize and concatenate the scripts to make fewer
HTTP requests.

I agree that if you're using the compiler at all then you _probably_
don't want to use WHITESPACE_ONLY, unless the other options cause issues
with specific parts of your code.


I also use WHITESPACE_ONLY, along with pretty print, as a re-indentation
tool when I'm studying obscurificated scripts.

Tim


Chris Price

unread,
Sep 13, 2011, 6:53:58 AM9/13/11
to closure-comp...@googlegroups.com
Don't want to teach people to suck eggs here but as I only just found
out about this feature I thought I'd share...

Introduced in a recent version of the Chrome devtools is a feature
which lets you turn on pretty printing of scripts using the {} button
next to the break on exceptions button.

Tim Wintle

unread,
Sep 13, 2011, 8:38:56 AM9/13/11
to closure-comp...@googlegroups.com
On Tue, 2011-09-13 at 11:53 +0100, Chris Price wrote:
> Don't want to teach people to suck eggs here but as I only just found
> out about this feature I thought I'd share...
>
> Introduced in a recent version of the Chrome devtools is a feature
> which lets you turn on pretty printing of scripts using the {} button
> next to the break on exceptions button.

Yup - it's awesome.

I'm normally checking for browser exploits though - so don't want it
going near a browser.


Reply all
Reply to author
Forward
0 new messages