0

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.

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

thanks @Edgar. I also read that nesting isnt required so you can have: $script('util.js', 'util'); $script('accounts.js', 'accounts'); $script.ready('accounts', function() { fnA });
to avoid race conditions you also need to have inside accounts.js: $script.ready('util', function...);

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.