Here is one simple way to
keep your code in check and avoid bugs: write a page routing function that executes only the JS that is needed
for that particular page.