Have a js file only for a single page?

I am adding a page to my site where I want to run a p5js sketch. But I have another sketch on a different page. The files are both active at the same time. Is there anyway I can just serve 1 file at a time on a specific page.