Hi, > > No, the order could be doA() doC() doB(). That is because doA() is called > > as > > soon as b.js is loaded but before c.js is loaded. The call to > > $.getScript() > > in b.js returns immediatelly and loads c.js assynchonously. Then b.js is > > finished and doA() is called while c.js is still loading. > > $.getScript works this way: download, evaluate, callback, finish. > Are you saying that the callback call occurs before evaluate has ended? > Well, that the evaluation of b.js ends before c.js is loaded?
No. In your example b.js is completelly evaluated before the doA() is called, but that only means, that the download of c.js has been started. As soon as that has finished, doB() is called, but that can be after doA() has been called. $.getScript() initiates the download and takes care that the callback is called after the download will have finished and then immediatelly returns. Some time later the download actually has finished and then the script is evaluated and the callback is called. The result for your example is: a.js: $.getScript('b.js',doA); - b.js begins to load a.js has finished - b.js is completely loaded b.js is evaluated -> $.getScript('c.js',doB); - c.js begins to load b.js has finished -> doA() is called - c.js is completely loaded c.js is evaluated -> doC(); c.js has finished -> doB() is called As you see the order will be doA(), doC(), doB(). Christof _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/