How can I include a javascript library like Underscore.js in the background page? I don't want the browser to have to load this up on every page.
Does @include work in background pages? Can it refer to scripts packaged with the extension?
Help get this topic noticed by sharing it on
Twitter,
Facebook, or email.
Twitter,
Facebook, or email.
-
EMPLOYEE
1Hey mjbrooks,
Unfortunately we do not support this feature (@include) in our background code.
We have added this issue to our tasks queue and it will be implemented in the very near future (~ the next 4 weeks).
Thanks for bringing this to our attention.
We will keep you updated on the subject through this thread. -
-
Thanks. Until then, is there a way to include libraries from the extension.js code? I don't want to use @include because the extension doesn't need to become fully active on every page, and I understand @include cannot be placed inside a conditional.
-
-
EMPLOYEE
1We have thought about a few alternatives for you:
1. If the code you want to include is your own code (or you have access to it) you can use appAPI.matchPages in the included code to check if the code should be run.
2. If you don't need access to the code from the extension and it doesn't use appAPI you can use appAPI.dom.addRemoteJS to inject the code into the document (and of course put appAPI.dom.addRemoteJS inside some conditional).
3. The last trivial option is to just copy-paste the code to you app code...
Tell me if you need me to elaborate on one of the above.
I know that these options are not ideal (or even good enough for you).
On a more optimistic note, we are currently working on a much more generic and robust solution for adding external resources to Crossrider apps.
A rough estimate for this new feature is about 4-5 weeks. -
-
Thanks for the suggestions. I'll probably be going with option #3 for now. The reason I can't use matchPages is that whether or not the code should be run depends on the page content, not the URL.
I'll look forward to the updates. -
-
would have addRemoteJS() injected code access to the appAPI or does it fall under the domain security policy?
-
-
Hello!
What about it now?
I tried and it seems to work in chrome but not in firefox (not tested anything else)...
FYI I'm using only linux...
Is it "normal" for now? Will it work the same in every browser soon?
thanks a lot! -
-
Hello there
Will I ever get an answer here or should I create a new topic for that?
please answer -
Loading Profile...





