Thanks everyone for your input. My other concern is that if i
completely modularize code to seperate includes, then i will lose the
one-time download / precaching benefit of a single js download.

Perhaps the best approach is to make sure that unnecessary event
handlers arent attached using something like what ambient impact
suggests, using simple switches to prevent segments of code from being
executed by pages that do not need them.

On Jun 27, 12:36 am, "..:: sheshnjak ::.." <[EMAIL PROTECTED]>
wrote:
> It actually does have a performance impact, even though we can't
> always "see it" on modern processors and javascript engines for
> desktop browsers. If you consider users with handheld devices that
> have functionality similar to PCs (and even take media="screen"
> instead of media="handheld" for styling), but have significantly less
> processing capacities, then you can see that even as good and clean
> code as jQuery core is preforming somewhat lazy. So, a large number of
> void requests for selecting nonexistent DOM elements does have a
> negative impact.
>
> What's hapenning internaly is basically evaluating document DOM and
> matching id '#very-specific-id-not-on-every-page' for every DOM
> element (just to conclude that they don't exist and instead of
> returning collection of objects, returning an empty collection), and
> repeating that for every line with $('something_here'). Then, it goes
> a step further and calls the function hover(), just to find out what
> to do if it is called on empty object (probaby return void).
>
> So if you do want to keep on with this coding strategy (or want to
> avoid rewriting of already written and debugged code), you could at
> least find some way of grouping events by functionality or some other
> criteria and call only groups that you need, depending on specific
> page content. Obvious example: you probably don't need any form
> validating events for pages that don't contain forms, or AJAX events
> for page with no AJAX at all... Call AJAX events group only for AJAX
> pages, form events only for page containing forms and so on. You can
> even let the scripts decide what groups to run by declaring which page
> goes to which category (could be multiple categories). For example
> declare a few group arrays:
> var AJAXgroup = new Array("first-ajax-page.html","second-ajax-
> page.html","third-ajax-page.html");
> $(AJAXgroup).each(function(){ if
> ( document.location.href.indexOf(this) declare AJAX events  });
> Again you will have few loops to run (and every loop impacts
> performance), but if you have say 75 events declared and call only 15
> that you need, it should be an improvement...
>
> I know answer was too long, but if you got this far it was worth
> writing...

Reply via email to