Activity Forums Salesforce® Discussions How do we include external JavaScript libraries in Salesforce Lightning Component?

  • Avnish Yadav

    Member
    July 17, 2018 at 9:31 am

    Hello Anjali,

    You can use external JavaScript library, by uploading script file as static resources and include in component by this statement

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

     

    Thanks.

  • Parul

    Member
    September 28, 2018 at 6:00 pm

    Reference a JavaScript library that you’ve uploaded as a static resource, use a <ltng:require> tag in your .cmp or .app markup.
    The framework’s content security policy mandates that external JavaScript libraries must be uploaded to Salesforce static resources. For more information on static resources, see “Static Resources” in the Salesforce online help.

    Here’s an example of using <ltng:require>.
    <ltng:require scripts=”{!$Resource.resourceName}”
    afterScriptsLoaded=”{!c.afterScriptsLoaded}” />

     

    hope this helps you!

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos