Put a unique id attribute in the <body> element for each page and use this to determine what your JS should do. This is what I do with my only mini file, which (as soon as it combines many smaller JS files) looks basically like this:
jQuery(function($){ if (!$('body#home').length) return; //... code specific to the home page }); jQuery(function($){ if (!$('body#contact').length) return; //... code specific to the contact page }); // etc. for each page
But you can just as easily write a more efficient single file, like:
jQuery(function($){ if ($('body#home').length){
Phrogz
source share