Using external javascript

Monkey Targets Forums/HTML5/Using external javascript

luggage(Posted 2012) [#1]
Hi There

I need to add some javascript back end functions into my HTML5 game. Currently I create an extern.js, and "import" that. I got that from...

http://www.monkeycoder.co.nz/Community/posts.php?topic=120

That works but the extern.js file is embedded in the main.js file. I really need to keep it seperate as the backend will be maintained by someone else and having it in one massive main.js is more than a little awkward. Is there any way to do that?

Thanks!


bruZard(Posted 2012) [#2]
you can do that with my "utils module" from http://www.sedm.de/monkey/utils.zip

the function "Include(url)" loads a external .js or .css at runtime.


luggage(Posted 2012) [#3]
Awesome. I might switch to that then as I ended up with a hacky workaround.

I used the link in my post to generate a set of functions called Extern_Foo. Then all they did was pass through to a function called BackEnd_Foo. BackEnd_Foo were in an external javascript file that's pulled in with the html. Works but seems a bit clumsy.

Thanks!