Javascript for different pages.

I've a single file of js with multiple scripts for different pages. Issue is I'm getting one element on a page that is not available on the other page, because of that the script of that page doesn't work. What should be the approach here. Make a different js files for different pages. Or is there another way.
Was this page helpful?