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

LWC > Load Script > Static Resource JS File > Not Working

Hi Folks,

I am building a LWC to load external JS script file in LWC. However whenever loadScript function is executing it is failing to load and there is not error received.

import { LightningElement, track  } from 'lwc';
import { loadScript } from 'lightning/platformResourceLoader';
import BrandfolderJS from '@salesforce/resourceUrl/BrandfolderJS';

export default class brandFolderLink extends LightningElement {
    @track blnBrandfolderJSInitialized = false;
    renderedCallback() {

        if (this.blnBrandfolderJSInitialized) {
        this.blnBrandfolderJSInitialized = true;

        loadScript(this, BrandfolderJS)
        .then(() => {
        .catch(error => {

JS file from Static Resource - Brandfolder JS (
I have created JS file as static resource (BrandfolderJS) and using it in LWC.

LWC is added to App Builder Page/Home Page and trying to load, however it is going to catch block in loadScript method without any error. Error variable is undefined.

Can you please help?

Thank you,
Jigar Lakhani

Divesh JaitleyDivesh Jaitley
I am having sames issues. Hope anyone got solution to this.
James KeoghJames Keogh
Hi @Jigar.Lakhani,

Have you figured out the solution to this problem?


No, Don't have any solution.
However it is not from salesforce, the issue is with Brandfolder JS Library.

Other Libraries are working fine with LWC.

Thank you,
Nicolás GomezNicolás Gomez
Hi, I have the same problem. So there isn't any solution for this? The library can't be used on salesforce?
IT Support EnessIT Support Eness
Having the same problem here with a different library. Does not load and error is undefined. Any solution yet?
same problem with amazon connect streams js file.

any solutions?
chris coates 19chris coates 19
Jigar, do you have a link to an example script library which does load ok, i think there might be a additional notation needed for LWC, but not having got anything to work so far either, seeing a working example would be great (and easy to compare the file structure).
IT Support EnessIT Support Eness
How can we inform SF that is erroneous regarding the catch method?
Omkar Deokar 2Omkar Deokar 2
@jigar.Lakhani  was this issue ever resolved? 
Was it something to do with salesforce's security updates regarding serving static resources via vf domain rather than lightning domain?
refer this StakeExchange (
Vivek SVVivek SV
I was able to fix this issue by switching the Security Level on the Experience Builder to "Relaxed CSP" and by turning off Lightning Locker
Dmitry Bakovich 7Dmitry Bakovich 7

In my case, the issue was that Lightning Locker did not like the imported library. The solution was to enable Lightning Web Security.

Brian Watts 21Brian Watts 21
I had a working 3rd party library when used in a `plain` LWC (extends LightingElement), but it didn't want to work when used in an LWC  that extends LightingModal.

I finally realized it was because I had been debugging with `Lightning Web Security` turned off.

Turning it on allows the loadScript function to work correctly in a LightningModal (but it makes debugging harder)
patrick devpatrick dev
I am facing the same problem. Is there any solution for this. I had used the mail back service for this but its not working.
capcut pro apk  (
Users have the freedom to merge many recordings into one to produce the whole video using KineMaster,
My issue (not with ChartJS which was working fine, but with PptxGen JS) was resolved by enabling Lightning Web Security (LWS).

Thank you Dmitry Bakovich 7!!