Matty F
Matty F

Reputation: 3783

$script.js nested dependencies

Is there a way to make the following work with $script.js:

control.js

$script('accounts.js', function() {
    // fnA
});

accounts.js

$script('util.js', function() {
    // fnB
});

I would have hoped that fnB is executed before fnA, but it's not. Therefore, namespaces and objects created in fnB are not available to fnA, namely the accounts functionality.

util.js contains only a namespace function.

Upvotes: 0

Views: 202

Answers (1)

Edgar Villegas Alvarado
Edgar Villegas Alvarado

Reputation: 18354

You should do this:

control.js
$script('util.js', function() {
    // fnB
    $script('accounts.js', function() {
       // fnA
    });
});

And it wouldn't be necessary for accounts.js to load utils.js.

Hope this helps

Upvotes: 2

Related Questions