How to add only used js to the page?
I use gulp and webpack to build. I used to make only one-page websites. so I collected all the scripts into 1 file and everything worked fine.
Right now I am making a multi-page site and ran into a problem: On one page I need to use a script, and on the other not. On the page where the script is not needed, an error appears due to the absence of an element to which it refers and from this all js stops working:
To place the code, please use CodePen or similar tool. Thanks you!