On 12/12/06, Karl Guertin <[EMAIL PROTECTED]> wrote:
> I'm interested in dojo's experimental javascript linker.
So I did a bit of testing to see what was up with this. The good news
is that it compiles cleanly (yay!) and it seems to work on the test
cases. The bad news is that the current version of the code removal
action (janitor) is built for the dojo codebase. Basically, the tool
builds an AST of the source code, detects assignments at the global
level and builds a callgraph off of that.
e.g.
dojo.a = function(){dojo.b();}
dojo.b = function(){alert('b');}
dojo.c = function(){alert('c');}
In the above example the linker recognizes all three assignments and
if dojo.a is the entry point, will correctly include dojo.b and
eliminate dojo.c. Not so with the following code:
dojo = {
'a':function(){dojo.b;},
'b':function(){alert('b');},
'c':function(){alert('c');}
}
Here the assignment isn't recognized as a function and no callgraph is
built. Unfortunately, the second example is how the MochiKit (and most
other JS libraries) is written, so it doesn't look like this linker
will be working on MochiKit very soon. Actually, it's a bit more
complex in MochiKit because MochiKit.Base.update() is used to modify
items after it's been declared, so I don't see how an AST parser can
reliably detect code written using this style.
Anyway, figured people might be interested.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---