Re: Writing a JS library in GWT?

2010-07-27 Thread S Rabin
I see. So when the only thing in my loadModule function is an export
call, and I export the method (via Ray Cromwell's gwt-exporter
library, which I was already using):

public void HelloTest(String id){
 DOM.getElementById(id).setInnerHTML("Hello World");
}

it should compile to 25kb plus a bootloader?  I'm not arguing that a
bootloader is a bad idea for larger code, but I was really just hoping
for a --disable bootloader compile option.

To address your concern that there is 'no possible way for the code
size to grow', and that the GWT compiler aggressively prunes dead
code, yes, I'm fully aware that it is designed to do that.  That's
why, when writing a function in GWT, I expect it to compile out to
something that doesn't exceed the size of handwritten JS for the same
purposes.  There are two options here: one, I'm missing some checkbox
(and it's not the OBFuscated option), or two, GWT is including a lot
more crap it thinks I need that I'm not aware of, hence why I'm asking
how to fix it.

As for whether I know better than Google when it comes to the
bootloader... yes, in this case, I do.  I anticipate this library to
be approximately 10kb of handwritten javascript, and I'm not doing
anything that should warrant more than 1 permutation beyond browser
specific speed optimizations.  Therefore, distributing the library as
a .js file instead of a bootloader plus 4 different permutations seems
like a better idea.

Is my only option here really to write my own linker to output one .js
file, no bootloader, no browser-specific optimizations?

On Jul 26, 12:42 pm, lineman78  wrote:
> First, let me start by saying that people are already writing
> javascript libraries using GWT and have been for some time.  Ray
> Cromwell created the GWT exporter library for this exact purpose for
> his own usage and open sourced it.  While bootloaders seem expensive
> it is the only way to deliver the most efficient code to the client.
> There is no possible way for code size to grow when compiled because
> if you go far enough every method will eventually make it to a JSNI
> method, so what you are missing in your calculations is all the code
> supplied by google and the small overhead code involved with the
> bootloader.  However, there is a linker available to create only one
> output, but in order for this to work the compilation must result in
> only one permutation, which is almost impossible unless you know the
> browser your client will be using.  You asked: "Is there a way to crop
> out all the unnecessary cruft GWT seems to think I need?".  You can
> write your own linker if you feel that you know better than google
> when it comes to the bootloader, but as far as the compiled code
> itself; the GWT compiler has very aggressive dead code elimination, so
> any output code will be used at some point.
>
> On Jul 26, 9:21 am, S Rabin  wrote:
>
>
>
> > I've done quite a bit of searching to find any information about this,
> > but it seems that people are more concerned with writing GWT libraries
> > to keep in GWT before compilation.
>
> > I would like to write the libraries I frequently use in my projects in
> > GWT, then compile and expose them to hand-written Javascript.  I have
> > several issues with the way GWT seems to handle what I want to do:
>
> > 1) Bootstrapping.  I understand that the iframe loading method is
> > highly efficient for large codebases so as to make the page non-
> > blocking, but for a small library bootstrapping is overkill.  To test,
> > I tried writing my TableGenerator library (a 7kb handwritten non-
> > minified library) in GWT.  The result was a 6 kb deferred binding
> > loader file (table.nocache.js) and 4 permutations of compiled JS
> > weighing in at 20-30kb each.  Which brings me to issue #2
>
> > 2) For compiling the code, GWT seems to produce LARGER codebases.
> > Fast, yes, but how does 3-5kb of source result in 20-30kb of compiled
> > javascript? Is there a way to crop out all the unnecessary cruft GWT
> > seems to think I need?
>
> > 3) I would prefer to not have a bootloader - I anticipate the compiled
> > form of my code is going to be smaller than the bootstrap code and
> > would rather it just be loaded.  Is there a compilation option to
> > disable permutations and output (obviously more to handle different
> > implementations) code that works in all browsers?
>
> > Sincerely,
> > Scott Rabin

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Writing a JS library in GWT?

2010-07-26 Thread S Rabin
I've done quite a bit of searching to find any information about this,
but it seems that people are more concerned with writing GWT libraries
to keep in GWT before compilation.

I would like to write the libraries I frequently use in my projects in
GWT, then compile and expose them to hand-written Javascript.  I have
several issues with the way GWT seems to handle what I want to do:

1) Bootstrapping.  I understand that the iframe loading method is
highly efficient for large codebases so as to make the page non-
blocking, but for a small library bootstrapping is overkill.  To test,
I tried writing my TableGenerator library (a 7kb handwritten non-
minified library) in GWT.  The result was a 6 kb deferred binding
loader file (table.nocache.js) and 4 permutations of compiled JS
weighing in at 20-30kb each.  Which brings me to issue #2

2) For compiling the code, GWT seems to produce LARGER codebases.
Fast, yes, but how does 3-5kb of source result in 20-30kb of compiled
javascript? Is there a way to crop out all the unnecessary cruft GWT
seems to think I need?

3) I would prefer to not have a bootloader - I anticipate the compiled
form of my code is going to be smaller than the bootstrap code and
would rather it just be loaded.  Is there a compilation option to
disable permutations and output (obviously more to handle different
implementations) code that works in all browsers?

Sincerely,
Scott Rabin

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.