Thanks for your reply. I'm self taught javascript im afraid so unaware
of the best way to do things and I coded the sliders a while ago. Will
take on board what you said and also do some research into best
practices. If you have any recommendations on what to read would be
much appreciated

Thanks

On Dec 18, 3:26 am, RobG <rg...@iinet.net.au> wrote:
> On Dec 17, 8:52 pm, Craig <cr...@europe.com> 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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to