top of page
Writer's pictureSaurabh Singh

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


7,833 views1 comment

1 Comment


Sridhar NareshIT
Sridhar NareshIT
Dec 15, 2023

This post made my work very easier. I appreciate your efforts on producing great content on LWC Components . Well done!


Like
bottom of page