So I have index.php like this
include..
switch $a {
case 1
include page1.php
break
case 2
include page2.php
break
case3
and so on...
}
include...
and in the end I have the script tag with the path to my script.js....
So everything is fine, every include outside the condition works as expected, the problem comes when one condition is verified and it includes a page inside the switch block... PhP side works fine, the problem is javascript...
As we all know, DOM is loaded first and in the end the file script.js, so once I load my website, those includes inside switch block are not loaded... what makes an error
TypeError:var is null
Because javascript can't get elements from the DOM because they are not loaded yet.. and this problem affects the rest of my webpage, because every script after that does not work...
Do you guys have some idea how to solve this? thank you in advance.