1

I've got a static resource with some javascript I've written which requires another static resource to work.

I would like to include the reference to the required static resource within my static resource, so that I only have to make the reference in one place, as opposed to creating a separate component with both references in/ referencing both resources each time they are used.

I think if I make a component with both references in I'll have to create one visualforce component and one component for lightning, perhaps another for web components?

So, it'll be easier to just reference it in the javascript. Is this possible?

2

You can't use the markup {!$Resource.MyJavascriptFile} in your actual static resource since Salesforce will not interpret that. It only evaluates that markup in the actual Visualforce page. However, you can still reference code from another static resource file just by calling it directly once they are both loaded in the VF page.

  • Another option that you might be tempted to try that "works", but only if both resources are in the same static resource bundle, is to apply a page relative URL when loading the other resource. This isn't really a good idea though - just explicitly load all relevant resources in the VF page in which they are used and @BryanAnderson said. – Phil W Oct 18 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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