Update: Essentially, due to edge cases in the way that the browser loads Javascript, and the workarounds libraries use to get around them, it’s as though every <script> tag has the async attribute. That is to say, scripts will be run in whatever order they are loaded, even if one is after the other in the document. This means that some standard library loading techniques will not work:
<script src="https://somewhere/my-library.js"></script>
<script>
MyLibrary.doSomething();
// ^-- this might fail, even though my-library.js is loaded earlier in the document,
// because it's loaded asynchronously
</script>
This is undesirable behaviour, and we are working on a reasonable workaround or (ideally) a fix. We’ll keep you posted!
In the meantime, the following rather awkward workaround does work: If you dynamically create a <script> tag to load the external library, you can set a function as an onload handler, which runs after the library has loaded:
<script>
function doTheThingOnceTheLibraryHasLoaded() {
// Do what you wanted to do here, eg:
MyLibrary.doSomething(...);
}
var s = document.createElement("script");
s.onload = doTheThingOnceTheLibraryHasLoaded;
s.setAttribute("src", 'https://somewhere/my-library.js');
var head = document.getElementsByTagName('head').item(0);
head.appendChild(s);
</script>
As I say, this is rather cumbersome, and we’re working on something better - but hopefully this will get you going for now!