Joachim Lundgren writes:
> But the question remains - if someone knows a way to do it only using
> JavaScript please share it! It must allow multiple dependancies, and
> deep too.
I believe that the idea I outlined would work, and using only
JavaScript. The same concept applies to multiple dependencies per file.
To avoid problems with deep nesting, instead of having each file write
SCRIPT tags directly (while still reading the file) how about using the
same idea of pushing info up to the top level to deal with? I don't
know if this idea will work any better, because I don't know why deep
nesting fails. But I would guess it is better to avoid actual recursive
loading by flattening it out. Here is a slightly more complex algorithm
for doing that:
As before, each file that is loaded would just define a code-wrapping
function for all of its code, followed by pushing a call to that
code-wrapping function on a global stack. But in addition, it would
push calls that load each of the dependencies. Back at the top level,
after having loaded each of the .js files required by the top level, the
stack is processed by popping one thing off and doing it. For a load, a
SCRIPT tag is written, followed by a SCRIPT tag to process the stack
again. When the SCRIPT tag for loading is eventually processed, that
would load the file which would then push a call of its own
code-wrapping function, and push more calls to load its dependencies.
Repeat until there is nothing left on the stack.
--
Daniel LaLiberte
[EMAIL PROTECTED]
http://www.HoloNexus.org/~liberte/
http://www.HyperNews.org/~liberte/
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev