For example I have a website with some pages like the following sample:
- login.html
- user-info.html
- products.html
- product.html
I have different scripts for these pages. So I have:
- login.js
- user-info.js
- products.js
- product.js
I can concat these files into one or import with ES6 modules and get "scripts.min.js".
However if I have in login.js something like:
document.ready(function() {
alert('Hello, this is logic for login.js');
})
then I get this messages for all pages.
I am searching for right way to divide logic between pages. All information about JavaScript architecture I found unfortunately was about SPA.
What's right way to organize JS structure in ordinary website to make it maintainable and scalable?