1

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!

1 Answer 1

5

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

2
  • @Shlomo, I've an extension with that working great. Now I want to organize my code in different files used at background scope, however I've seen in the docs that ´appAPI.resources.includeJS´ is not available at background. How can I do?
    – Diego
    Mar 13, 2014 at 12:51
  • Currently, for the background scope we suggest trying the following which works in most cases: $.globalEval(appAPI.resources.get('js/script.js'));
    – Shlomo
    Mar 13, 2014 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.