On Thu, 10 Feb 2011 21:02:43 -0000, Tab Atkins Jr. <jackalmage at gmail.com>
wrote:
> Nope, execution is the culprit here, as function declarations are
> actually executed code. Saying "function foo() { bar(); }" is the
> same as saying "window.foo = function(){ bar(); };" (module a few
> irrelevant details). The act of defining functions requires executing
> functions (hidden behind the syntax of an operator, but still).
>> Solving this does require deferring execution entirely, like the GMail
> Mobile team was able to do with the comment hack.
Are you sure about this? As far as I understand it, execution of:
window.foo = function(){ /* nothing */ }
and
window.foo = function(){ crazy(); amount(); of(); code(); }
is basically the same — just linking of function expression to global
scope (so that referenced globals can be found *later* when function body
is executed) and assignment of Function object to window.foo.
So once script is parsed, I assume that definition of a huge function
should not be any slower than definition of an empty function.
--
regards, Kornel