function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nick ButlerNick Butler 

ltng:require does not work with lightning out

I can include an external resource in my component and it will work in salesforce. However it does not work when using the component in "lightning out".

For example. This is the correct way to include a static resource javascript library. 
<ltng:require scripts="{!$Resource.FileSaver_js_zip + '/FileSaver.js-master/FileSaver.js'}" />

works just fine in salesforce.

using this component in "Lightning out". I get the error due to trying to pull in the static resource on the 'origin host' rather that my salefsorce org.

aura_proddebug.js:15863 GET https://{origin_host}/resource/1481801758000/FileSaver_js_zip/FileSaver.js-master/FileSaver.js 404 (Not Found)

Is there a work-around? If not this will be very limiting.
Hi Nick Butler

You can try this 


        styles="{!$Resource.SLDSv1 + '/assets/styles/lightning-design-system-ltng.css'}"

        scripts="{!$Resource.jsLibraries + '/jsLibOne.js'}"

        afterScriptsLoaded="{!c.scriptsLoaded}" />


Due to a quirk in the way $Resource is parsed in expressions, use the join operator to include multiple $Resource references in a single attribute. For example, if you have more than one JavaScript library to include into a component the scripts attribute should be something like the following.

    $Resource.jsLibraries + '/jsLibOne.js', 

    $Resource.jsLibraries + '/jsLibTwo.js')}"

Ravi Dutt SharmaRavi Dutt Sharma
Hi Nick,

Did you find a solution for this? The solution mentioned in the above comment does not work for me when I am inside a lightning out app.