I\'m adding some tags dynamically to the head element after page load. I understand the scripts are loaded asynchronously, but can I expect them
No, you cannot expect that all browsers will defer execution of both scripts until both are loaded (**especially when you are adding them dynamically).
If you want to execute code in B.js
only after A.js
is loaded then your best bet is to add an onload
callback to A.js
that sets a variable and another one to B.js
that checks to see if that variable has been set, then it executes the necessary function in B.js
if it has (and if A.js
has not loaded, it starts a timer that periodically checks until it has loaded).