Question

I'd like to port my chrome extension using crossrider. I'd also like to maintain different extension js files instead of one gigantic extension.js file.

I am assuming I can add the extension js files as "Resources".

Is that correct?

Will js functions added to Resource files be automatically accessible within extension.js or do I need to clarify paths?

Or is there a manifest file I can access and modify to let crossrider know that I have multiple extension pages?

Thanks!

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top