I use one js file for different pages of the site. There is a problem. Not all features are needed on every page. Therefore, after connecting the script, I insert and write what functions I need.

But when I watch other people's scripts, I never see such inserts. How to connect functions to the page?

Note: my code usually looks like this

<script src="code.js"></script> <script> toDoSome(); toDoSome1(); ... </script> 
  • one
    "do insert" - insert what? - Igor
  • updated the question to clarify - Zhenya Vedenin
  • It is not clear why this is? - andreymal
  • You just need to qualitatively separate the scripts for different pages or is there another method? - Zhenya Vedenin
  • 2
    Select the necessary functions in a separate file and connect only it - Dmytryk

0