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).


1 Answer 1


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. Oct 18, 2019 at 16:19
  • Will check and revert. @user2815826 Oct 18, 2019 at 16:26
  • @salesforce-sas, I have a similar question on this thread for open source lwc, "salesforce.stackexchange.com/questions/316904/…" would highly appreciate your thoughts on it.
    – gs650x
    Aug 16, 2020 at 17:58

You must log in to answer this question.

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