why separate <script> segments? trouble with closure compiler advanced?

8 views
Skip to first unread message

Sarvi Shanmugham

unread,
Oct 30, 2013, 1:58:58 AM10/30/13
to pyjs-...@googlegroups.com


Is there a reason for distributing multiple script segments inside a single html file?
Can they be one big compiled script segment with all the code?

Has anyone used closure compiler ADVANCED_OPTIMIZATIONS and got things to work?

Why do I ask?
   1. I haven't been able to get it to work. I got pyjscompressor.py to do it. But the page does not work.
   2. ADVANCED_OPTIMIZATIONS does extensive inlining and dead code removal. And from what I have played around with, 
it will remove what it thinks is dead code. And when each javascript file is compiled separately as pyjscompressor does, it seems to
removing code.
   3. From what I can tell, for advanced optimization to work,  they have to be compiled together or if compiled seaprately with extensive externs/expose definitions.

Sarvi


Kees Bos

unread,
Oct 30, 2013, 2:29:14 AM10/30/13
to pyjs-...@googlegroups.com
On Tue, 2013-10-29 at 22:58 -0700, Sarvi Shanmugham wrote:
>
>
>
> Is there a reason for distributing multiple script segments inside a
> single html file?

I think there is/was. Maybe it was just because of opera. It couldn't
handle large script elements.

> Can they be one big compiled script segment with all the code?

Probably yes. But most people (with large apps) use dynamic loading, so
they don't have a single large file. With separate script segments in
the monolithic html this resembles (a bit) the dynamic load use case.

Obviously, with dynamic load you can't compile them all together.

However, you might parse the html file (with some regex) and put all
script elements into one script element.
>
> Has anyone used closure compiler ADVANCED_OPTIMIZATIONS and got things
> to work?

I'm not sure, but if I did, that would be a looong time ago. I didn't
want to find out all the possible externs/expose. I think that that's
why I changed all foo.bar to foo['bar'] in the js code.
Reply all
Reply to author
Forward
0 new messages