Using resources, you can maintain files such as js, css, html, images, ... and include them as required. You can even maintain them in a folder structure that meet your needs. For more information, see appAPI.resources.
In your scenario to include a js resource file in your extension.js file, simply use appAPI.resources.includeJS and the code is immediately available thereafter in the extension.js file.
For example, if you have a resource file named script.js in a folder named js, you can include it as follows:
extension.js:
appAPI.ready(function($) {
appAPI.resources.includeJS('js/script.js');
writeToConsole('Hellow World');
});
script.js in folder js:
function writeToConsole(msg) {
console.log(msg);
}
Disclaimer: I am a Crossrider employee