My question is similar to this. It seems we need to upload the Javascript library as a static resource before we can use it in LWC.

I've got a payment gateway JS library which I need to use via CDN without uploading as a static resource, which I believe they would update without notice.

How do you use JS libraries, etc. in LWC without uploading as a static resource?

Any workaround to avoid keeping copies and referring CDNs? I did create a CSP Trusted Site for the CDN, but since <script> cannot be used on LWC, not sure where to look for.

1 Answer 1


You would need to add the script tag to an aura component then load your LWC inside the aura component also. Also if the script calls out to another source inside it you will need to add them to the trusted sites also.

  • Don't think we can add script tag in aura? I tried ltng:require , but it doesn't allow CDNs yet as per SF doco somewhere I saw. Commented Oct 27, 2020 at 6:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .