When I develop a site, I always save it inside a folder called js , and the file name is usually acoes.js . What happens is that I call this file on each page. And sometimes, I create a function for a particular page, and when I'm in another, because there is neither class nor the id containing this function, / p>
I always have to check whether it exists or not, like this:
if($('#MINHA_ID').length>0){ MINHA FUNÇÃO});
I'm doing this check, that this id is being used or not on this page, no problem.
Is this the right way? or should I make a separate js for each page?