Nesting a second $.when() inside done()

252 Views Asked by At

"Is it possible to nest a second $.when().done() inside of another $.when().done(). It seems to work sometimes but not consistently. The problem seems to be that the second done() does not always fire. I included a sample of what I am trying to do below.

$.when(
    // config file
    $.getScript("config.js")
).done(function(){
    $.when(
        // load js files
        $.getScript("file1.js"),
        $.getScript("file2.js"),
        $.getScript("file3.js"),
        $.getScript("file4.js"),
        $.getScript("file5.js"),
        $.getScript("file6.js")
    ).done(function(){
        console.log("done")
    });
});
0

There are 0 best solutions below