I currently have a single jQuery script page that I include in my ScriptManager on my MasterPage (I use ASP.NET). All of my custom scripts for all my pages go in this page. I know some people like to break it up into multiple pages but I prefer having them all in one place. Anyways, I have one $(document).ready(function(){ //do stuff// });
on this page. All of my other functions I name and then place in the document.ready function, ie:
$(document).ready(function(){
Function1(); //necessary for page1.aspx, page2.aspx but not 3 or 4
Function2(); //etc., necessary for some but not other pages
});
function Function1() {
// whatever, etc //
}
My question centers around the efficiency of this. A lot of these functions only have any sort of application on certain pages, but not on all. Would it be better to include some page-specific coding, ie, determine what page we're on, and then if we're on the correct page, go ahead and perform the function, or does it not even matter? I was under the impression that it didn't matter, but I would like to be sure.
Thanks