top of page

How to use Multiple JS in LWC component


In lightning web component, you can use more than one JavaScript and decentralize your code, This also helpful in cases where you get 'error of large file' error while deploying your code to org.


In this example, I will show how can we include an extra js file in lwc bundle and how to modify DOM in this new JS.


HTML -



Default Javascript -



Additional Javascript - util.js


in additional javascript, we have exported 3 functions. we have also took reference of this.template in local variable template, so that we can modify DOM, in this javascript as well.


all the function, we need to use has to exported in js file and has to be imported in default js file. you can export variable also.


for More help, you can refer to below url


6,572 views1 comment
bottom of page