We have a lightning component thats part of our appexchange package. We have development environments with no namespace, a beta/staging package namespace, and our production package namespace. Is it possible to make the following namespace dynamic?

<ltng:require scripts="{!$Resource.yournamespace__resourceName}" styles="{!$Resource.yournamespace__resourceName}" />


  • 1
    In terms of workarounds, probably worth noting that this is one of those things DX solves since it lets you have scratch orgs with the same namespace - so any solution you come up with should probably assume you won't need it once you implement a DX workflow Oct 1, 2018 at 13:28

3 Answers 3


It's not possible to make it dynamic, but you can try doing it like this:

<ltng:require scripts="{!$Resource.yournamespace1__resourceName}" styles="{!$Resource.yournamespace1__resourceName}" />
<ltng:require scripts="{!$Resource.yournamespace2__resourceName}" styles="{!$Resource.yournamespace2__resourceName}" />
<ltng:require scripts="{!$Resource.yournamespace3__resourceName}" styles="{!$Resource.yournamespace3__resourceName}" />

Since only one reference is valid in any given org, the resource would only be loaded via the valid reference.


I faced the same issue.

And there is no possible way to make it dynamic. I have added the namespace manually in it and then commit it to production.

You can check out the below link. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/namespace_using_reference.htm


try this

<aura:attribute name="ns" type="String" description="pkg namespace" />
<ltng:require scripts="{! '/resource/<yourfoldername>/' + v.ns + '__' + <your resource name>}" />

Be sure to include any additional folders in the path with the folder name

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .