Checking for the presence of a  relevant element should do:

$(document).ready(function(){

if ( $('#categories').length )
        ManageCategoriesClick();

if ( $('#ghosts').length )
        HideByDefault();

if ( $('#split').length )
        PrepareSplitForm();
});

Alternatively you could add a different class to the body of each
page, then use this rather amusing construct:

$(document).ready((function(){
  var is = function(v){ return ++document.body.className.indexOf(v) };

 return(
   is('categories')
     ? ManageCategoriesClick :
   is('hidebydefault')
     ? HideByDefault :
   is('form')
     ? PrepareSplitForm :
   is('advert')
     ? SetUpAdvertPopup :
   function(){} //nothing
 );

})());

(anonymous function returning the relevant function)

In the second case only a single function can be returned, anyway I
hope this can give you some ideas.

- ricardo

On Feb 7, 10:43 pm, Beau <zar...@gmail.com> wrote:
> So I have my document.ready function, looks something like this:
>
> $(document).ready(function(){
>         ManageCategoriesClick();
>         HideByDefault();
>         PrepareSplitForm();
>         SetUpAdvertPopup();
>         CheckAll();
>         CheckNone();
>         EditCategoryInPlace();
>         PreparePaneLinks();
>         PrepareToolTips();
>
> });
>
> Those functions all call things, but many are for specific pages. Does
> it slow the page down if they don't find the elements the functions
> call? What's the best way to call functions that are specific to a
> single page?
>
> -beau

Reply via email to