On 05/02/2008, Rauan Maemirov <[EMAIL PROTECTED]> wrote:
>
> I have some doubts on $ performance. Is it better to use multiple $(),
> than e.g. elem = $('elem') and then using elem or elem would be just a
> link for $('elem')?

>From general programming sense, if you have to keep calling a method
on an object, it will be slower than keeping a copy of the result of
the first call.


But this has to be balanced with readability and suitability.

If you only have 1 or 2 (or maybe 3) calls to elem, then MAYBE you get
away without it.

If that is in a loop of hundreds, then maybe not.

If you can chain the use ...

$('elem').method1().method2().method3();

then that is only 1 call.



-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to