I couldn't find a way to do it without the callback as a global function. I need to execute the callback when the file ace.js is fully processed so I'm calling window.aceScriptLoaded at the end of that script.