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
Asad Mahmood 6Asad Mahmood 6 

Third party js library will not load in lwc

Hi guys, 

I have been trying to third party js file called oidc-client.js from static resource and unfortunately will not load the script. However, when I try to load jquery js file, it will load. I can see in the network tab of Google chrome developer tools that oidc js was loaded successfully. 

There's no error stack other than undefined. 

I downloaded the file from

​​​​​​Any ideas why It won't loadscript?? 

Sorry I am not leaving any code snippet because I am raising this issue using my phone. 

Many thanks
AbhishekAbhishek (Salesforce Developers) 
Hi Asad,

You can use third-party JavaScript libraries with Lightning web components. For example, use a library with interactive charts and graphs or one to reduce code complexity.

The above blog have complete information.

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Asad Mahmood 6Asad Mahmood 6
import { LightningElement } from "lwc";
import { loadScript } from 'lightning/platformResourceLoader';
import oidc from '@salesforce/resourceUrl/oidc';

export default class MainComponent extends LightningElement {
renderedCallback() {
        loadScript(this, oidc),
    .then(() => {
      alert('oidc loaded');
    }).catch(err => {
      alert('oidc not loaded')

Hi Abishek,

Please see above code, the library will not load, it works fine in classic page but not in LWC.

If you have time then could you please try from your side in sample app to see if it loads
here's the link:
AbhishekAbhishek (Salesforce Developers) 
Let me check and if I find anything useful let you.
Naresh Vaddepallli GNaresh Vaddepallli G
I solved similar issue reported here with the help from
Surya Rama PedapatiSurya Rama Pedapati
Hi @Asad, I'm using the same library in LWC, and I'm getting the same error "undefined" while loading the .js files. Do you remember how the issue was resolved back then ?
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!!