How to include 3rd party library (eg: whatever.min.js)

The only way i’ve found to include an external library is to copy-paste the contents of a xyz-min.js file into a JS code block on a scene->start event. That actually does work, it’s just a little ugly with clutter.

Is there a nicer way to include an external JS lib ?

I’m currently using external events to store the JS code and add the functions I need under Functions/Behaviors in order to be available to use through the Event Editor.

cool that would at least be tidier - can you explain how to do this ? i have created an ‘external events’ entry and added some JS code block there, but it doesn’t run… how do i make the scene start running those external events ?

Is there a function that should be called when the external event is included in a scene or do you need to selectively call functions?
In the first case, just add the function call at the end of your JS code block. In the second case, use the Functions/Behaviors menu to create a custom function that will actually contain the JS function call. This might help you a bit:
http://wiki.compilgames.net/doku.php/gdevelop5/events/functions

1 Like