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.


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,174 views1 comment

1 commentaire

Sridhar NareshIT
Sridhar NareshIT
15 déc. 2023

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

bottom of page