I have created a folder name myResources
. It has two sub folders styles
and scripts
. scripts
folder has two files js1.js
and js2.js
. styles
folder has one file styles.css
.
myResources->scripts->js1.js
myResources->scripts->js2.js
myResources->styles->styles.css
And I am trying to load it as below
<ltng:require styles="/resource/myResources/styles/styles.css"
scripts='/resource/myResources/scripts/js1.js,
/resource/myResources/scripts/js2.js'
afterScriptsLoaded="{!c.setup}" />
I have also tried
<ltng:require styles="{!$Resource.myResources+ '/styles/styles.css'}" />
<ltng:require scripts="{!join(',',
$Resource.myResources+ '/scripts/js1.js',
$Resource.myResources+ '/scripts/js2.js')}"
afterScriptsLoaded="{!c.setup}" />
But not luck so far, I don't know what I am doing wrong.
My static resource name is myResources
.
Note: I have upload them individual files not .zip file It loads successfully.
Following this tutorial Loading External JavaScript And CSS Libraries To Lightning Components
Best Answer
Since your folder name and static resource name both are
myResources
, its leading upto a confusion.You need to include your folder name as well in the path like this.