i think my question is a little bit stupid, but I have a problem. There`s a few html pages, for ex.: index.html and rooms.html etc... And a main.js file with scripts for all .html pages. The problem is that i have a variables, like
const HTMLelement = document.querySelector('.className');
and some functions to work with this HTMLelement. But, this element is only on index.html page, and when im on rooms.html page, i have an error, cause HTMLelement is not defined and other script does not exists (its important, cause some html build by script.) Also, in main.js I have scripts for all pages, so I cant create new .js file...
So, what is the best way to separate
scripts for different html pages?