At times we might have to make use of a third party library and use it in LWC. There is no way we can use a CDN and include it in <script></script> tags in a Lightning Web Component.
So the route that we are gonna take it is using static resources in Lightning Web Component.
Create or download the library file and push it to static resources. From the static resources using the standard out of the box named imports to fetch a reference to Static Resource and use it in the controller.js file.
This is how the controller.js file is going to look like.
This is how the static resource is going to look like.
Using static resources in Lightning Web Component is going to be very handy as we can provide a very high level of abstraction and have only the necessary code in the Lightning Web Components.
Subscribe to Salesforce Casts
Get the latest posts delivered right to your inbox