1

I want to build a lightning web component which involves the use of jquery and bootstrap. The Lighting Web Component involves multiple child components. I was going through the salesforce document on how to load the external library on LWC. The document states that we need to upload the file in static resource and then use renderedCallback to load the files on the component.

My question is: Do I need to do all this to import the jquery and bootstrap on all the components(parent and child).

3

Firstly, if you are absolutely sure that you cannot get the needed functionality using standard Javascript and SLDS classes, only then you should go for Using Third-Party JavaScript Libraries.

Option 1: You should use import statements in every component that need to use this library.

Option 2: You use import these libraries in base class and extend that class in every component that needs these libraries.

import MyBase from 'c/myBase';

export default class MyComp extends MyBase {
    ...
}
  • If I am using the base component and extending that in all other child components, the library is loaded all the time. I mean if I have 5 child components each extending the base component wrapped under parent component then Jquery libraries and bootstrap are loaded 5 times. – user2815826 Oct 18 '19 at 16:19
  • Will check and revert. @user2815826 – salesforce-sas Oct 18 '19 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.