toyflish
2007-Oct-03 19:19 UTC
Event.observe over huge count of elements slows down reaction
I got a div with id="small_matrix_container" surrounding 814 links with images. When I attach a mouseovereffect with Event.observe("small_matrix_container", ''mouseover'', function ...... the resulting effect comes fast on the bottom of the page on the last images and get''s slower when I go to the top of the page. How does observe works ? Is there is stack where the last Objects are found fast and the first take long time to look up. Does somebody know a better way to solve this. the code is on http://shishabrand.com/dudism/ there are the 814 images and two functions Event.observe("small_matrix_container", ''mouseover'', function(event) { var element = Event.element(event); if ( ''IMG'' == element.tagName && element.hasClassName(''shade'') ) { element.removeClassName(''shade'') element.addClassName(''noshade''); } }); Event.observe("small_matrix_container", ''mouseout'', function(event) { var element = Event.element(event); if (''IMG'' == element.tagName && element.hasClassName(''noshade'') ) { element.removeClassName(''noshade''); element.addClassName(''shade''); } }); Regards Kai SHISHA Team --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
RobG
2007-Oct-04 14:05 UTC
Re: Event.observe over huge count of elements slows down reaction
On Oct 4, 5:19 am, toyflish <toyfl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I got a div with id="small_matrix_container" surrounding 814 links > with images.That is a very unfriendly thing to do - a 2.6MB web page is absurd. You could at least warn people here of that.> When I attach a mouseovereffect with > Event.observe("small_matrix_container", ''mouseover'', function ...... > the resulting effect comes fast on the bottom of the page on the last > images and get''s slower when I go to the top of the page.Have you tried attaching the function inline and compared the results? In Safari 3.0 it seems to run at the same speed regardless of which image I click on, which is what I''d expect. Attaching the function inline would also mean that it is attached much sooner than when the entire page has loaded as you have now. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---