in short: include file only once in the same context if included more than once.
Ti.include("foo.js", "bar.js"); //in foo.js Ti.include("needed.js", "needed2.js"); //in bar.js Ti.include("needed.js");
in this trivial example needed.js included twice, i know that some may suggest to use flat inclusion like
Ti.include("foo.js", "bar.js", "needed.js", "needed2.js");
but this approach isn't good for large projects and alot of dependencies.
every file should include its needed files without caring about if the file included before or not.
I implemented a simple script loader that loads into the current context exactly once in Helium, my little helper library for Titanium - you could give Helium a try or steal that bit of code - whole impl is 9 LoC.