I've got compiled a lib using emscripten, generating mylib.js.
Basically its interface is declared at the end of mylib.js:
var MyLib = function () {
that = {};
that.ptr = MyLib_constructor();
that.destroy = function () {
MyLib_destructor(that.ptr);
};
that.doSomething = function () {
MyLib_doSomething(that.ptr);
};
return that;
};
I'm integrating it in an HTML page like this:
<html>
<head>
<script src="mylib.js"></script>
</head>
<body>
<script>
var MyLibInstance = MyLib();
/*...*/
</script>
</body>
</html>
However in the console I've got the following warning:
Successfully compiled asm.js code (total compilation time 17ms; unable to cache asm.js in synchronous scripts; try loading asm.js via or createElement('script'))
1. Does this impact performance? How?
I then try to make the script call async:
<script src="mylib.js" async=true></script>
Then it's OK for the cache:
Successfully compiled asm.js code (loaded from cache in 48ms)
But then MyLib is not found anymore:
ReferenceError: MyLib is not defined [Learn More]
2. Is there an example on how to make this code async and have the interface visible to my script?