I'm trying to use an external javascript library in my lightning web component, this include two external CDNs one css and one js.

How can I load them in my component?


1 Answer 1


Repasting from here

  1. You cannot have direct CDN in LWC component. Download the file , create static resource and refer it in LWC component using loadScript.

  2. Create CSP Trusted Sites to google sites so that the static resource js can interact with host site.

  3. Note that I found bug some days back that just by above steps, it may not work. Not sure if its fixed now. So, the workaround is to Whitelist Third-Party Hosts for Lightning Communities. You can do it in any community. I know it sounds weird that for accessing it in normal lightning experience, you need to add it in community, but this is just a work-around if above 2 steps does not work.

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