Out of order JS file execution in WebKit

Werner Thie <[email protected]> Mon, 12 Apr 2010 20:23:22 +0200
Newsgroups gmane.comp.python.quotient.dev
Organization THIEngineering AG
Message-ID <[email protected]>
Hi

Seems that the quest for more speed in JS execution goes into the next 
round. WebKit does not load and execute JS files in the order they are 
specified either by '// include' or in the header of the LivePage.

The problems I observed were that depending on load/response time my 
LivePage based RIAs sometimes worked perfectly and sometimes simply 
stopped working at certain stages in the WebKit based browsers.

After some digging and inserting alert's in the JS files before creating 
a new class, the alerts showed that base classes were sometimes empty 
and therefore the class trying to inherit died.

A simple solution was to push the '// include' of the base classes back 
to some early point when loading the initial page, the after wards 
injected LiveElements then do find their base classes because everything 
is settled by then.

I'm not familiar enough with the import system used by nevow/athena to 
see a path for a solution but maybe somebody with the knowledge can 
enlighten me if more refined solution could be built into nevow/athena.

Question: Would it be feasible to extend the '// include' system such 
that it can be guaranteed that a following constructor for YYY can rely 
on the base class XXX being present?

// import Nevow.Athena
// import common.xxx

///// code to check and gurantee the presence of common.xxx
check: function() {
   if (common.xxx.XXX == null)
     Divmod.Runtime.DelayedCall(100, check);
}
check();

common.yyy.YYY = common.xxx.XXX.subclass('common.yyy.YYY');

common.yyy.YYY.methods(
   function __init__(self, node) {
     common.yyy.YYY.upcall(self, '__init__', node);
   }
);

Thxs for your opinions!

Werner