I'm trying to use jQuery from one of my component helpers inside Community Builder (Lightning Component). I'm concerned about reference conflicts across the various components that may be used, so I don't want to use a static resource reference within the component, itself.

I found this recommendation to be that you include the script reference in the section for the entire community (which would be a great solution, in my case).

I tried adding the script reference in this section for my community, but it didn't work. I'm using Winter 16.

1 Answer 1


You can use ltng:require to make sure your jquery is encapsulated in every component .Loading the external script on the head might not be available inside each of the component while ltng:require ensures you have files completed loaded

<ltng:require scripts="{!$Resource.***resourceName***}"
    afterScriptsLoaded="{!c.afterScriptsLoaded}" />

Note the Jquery has to be inside the static resources .

  • As I mentioned, I'm concerned about reference/version conflicts. What are the precautions that should be taken to mitigate these risks? The conversation about loading external .js resources in the community seem to be divided. [releasenotes.docs.salesforce.com/en-us/spring16/release-notes/… recommendation) that I mentioned is in the release notes from the development team. Commented Nov 8, 2016 at 15:50

You must log in to answer this question.

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