On Dec 17, 8:52 pm, Craig <[email protected]> wrote:
> site im developing is not live but similar tohttp://www.aspecto.co.uk/
>
> Is there much use in creating a slider function to run all the sliders
> from would this make much of a difference?
It might make the code tidier and get rid of some global variables,
but I doubt that it will have any effect on speed.
There seems to be an over reliance on try..catch, which should be used
about as often as eval (i.e. rarely and usually when there is no other
option). It seems to be used whenever the code author was too lazy to
test if an object exists before trying to do something with it, e.g.
try
{
width_r = ($('side_right').scrollHeight - $
('side_right').offsetHeight);
}
catch(error)
{
width_r = 100
}
Presumably that was done because an element with id side_right may not
exist. Consider:
var el = $('side_right');
// If that didn't return something, deal with it
if (!el) return;
// Otherwise, use el
width_r = el.scrollHeight - el.offsetHeight;
Then there is:
if(width_r < 1)
{
width_r = 1
}
If width_r must have a value within a specified range (in this case it
seems to be that it must be >0), it should be dealt with when it is
set and the reason should be documented:
// width_r must have a positive integer value
width_r = (el.scrollHeight - el.offsetHeight) || 1;
and so on. If you want analysis of your slow code, you'll need to
post, or link to, an example that is slow.
--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---