Jan ^ SoRDiD
2007-Aug-21 14:40 UTC
Prototype Element.up() with index parameter extreme slugish in IE on big page [workaround inside]
The usage of Element.up( parameter ) is extreme slugish in combination with IE and a big page (tested page is 300k). If you would do a $(''element'').up(1) its more than 100 times slower than doing $(''element'').up().up(). (this is the workaround for those who dont want to edit their prototype.js) That most likely results from the element.ancestors() call inside up. up: function(element, expression, index) { element = $(element); if (arguments.length == 1) return $(element.parentNode); var ancestors = element.ancestors(); return expression ? Selector.findElement(ancestors, expression, index) : ancestors[index || 0]; }, an fix might be this: up: function(element, expression, index) { element = $(element); if (arguments.length == 1 || ( !expression && index == 0 ) ) return $(element.parentNode); return expression ? Selector.findElement(element.ancestors(), expression, index) : element.up( index-1 ); }, i try that later, but atm i only have protactulous on my server, maybe someone here has a better solution? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jan ^ SoRDiD
2007-Aug-21 14:58 UTC
Re: Prototype Element.up() with index parameter extreme slugish in IE on big page [workaround inside]
i have analysed this further: Element.ancestors call wasn''t the problem. The problem is that "Selector.findElement" is the first who finds out that the first parameter is the index, and not an expression. and this method allways uses "Selector.matchElements", which is slower than using the fastpath defined in "Element.up" -> "ancestors[index || 0]" which is only used if you write "$(''element'').up(false,1)" adding this to the beginning of the Element.up method enables the fastpath even with ".up(1)" calls: if (typeof expression == ''number'') { index = expression; expression = false; } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jan ^ SoRDiD
2007-Aug-21 15:04 UTC
Re: Prototype Element.up() with index parameter extreme slugish in IE on big page [workaround inside]
Resulting in: up: function(element, expression, index) { element = $(element); if (arguments.length == 1) return $(element.parentNode); if (typeof expression == ''number'') { index = expression; expression = false; } var ancestors = element.ancestors(); return expression ? Selector.findElement(ancestors, expression, index) : ancestors[index || 0]; }, --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jan ^ SoRDiD
2007-Aug-21 15:23 UTC
Re: Prototype Element.up() with index parameter extreme slugish in IE on big page [workaround inside]
Sorry for spamming, but i found a way to further improve the method by making the detection of "expression is index" a shortcut. up: function(element, expression, index) { element = $(element); if (arguments.length == 1) return $(element.parentNode); var ancestors = element.ancestors(); if (typeof expression == ''number'') return ancestors[expression]; return expression ? Selector.findElement(ancestors, expression, index) : ancestors[index || 0]; }, --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Martin Ström
2007-Aug-21 21:58 UTC
Re: Prototype Element.up() with index parameter extreme slugish in IE on big page [workaround inside]
Looks promising. Try to submit a patch (howto @ <http://prototypejs.org/contribute>). I think the core team will be more interested if you provide benchmarks and unit tests as well. Ciao Martin On 21/08/07, Jan ^ SoRDiD <jan-ZTN9A5SdVC+zQB+pC5nmwQ@public.gmane.org> wrote:> > Sorry for spamming, > but i found a way to further improve the method by making the > detection of "expression is index" a shortcut. > > up: function(element, expression, index) { > element = $(element); > if (arguments.length == 1) return $(element.parentNode); > var ancestors = element.ancestors(); > if (typeof expression == ''number'') return ancestors[expression]; > return expression ? Selector.findElement(ancestors, expression, > index) : > ancestors[index || 0]; > }, > > > > >-- burnfield.com/martin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jan ^ SoRDiD
2007-Aug-22 07:57 UTC
Re: Prototype Element.up() with index parameter extreme slugish in IE on big page [workaround inside]
Thanks. I have made benchmarks and submited it here : http://dev.rubyonrails.org/ticket/9330 Looks like even FF profits from the Patch. About the unit tests, sadly i don''t use Ruby on Rails here, just PHP5 with Prototype. Started learning Ruby and Rails, but don''t have an usable environment here at work. ~ Jan On Aug 21, 11:58 pm, "Martin Ström" <martinstromli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Looks promising. Try to submit a patch (howto @ > <http://prototypejs.org/contribute>). I think the core team will be > more interested if you provide benchmarks and unit tests as well. > > Ciao > Martin > > -- > burnfield.com/martin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Martin Ström
2007-Aug-22 12:50 UTC
Re: Prototype Element.up() with index parameter extreme slugish in IE on big page [workaround inside]
You dont'' have to use RoR to write or test Prototype. It''s a lot easier if you have Ruby installed (to build the dist from the source files) but it''s not required. You can also run the tests manually by just open the html-files in the browser you want to test. There are one-click installeras for ruby on both mac and windows so it should not be too hard to set it up. Look at the tests here <http://dev.rubyonrails.org/browser/spinoffs/prototype/trunk/test/unit>. These are regular html files with some javascript files included to provide the test framework. Good luck On 22/08/07, Jan ^ SoRDiD <jan-ZTN9A5SdVC+zQB+pC5nmwQ@public.gmane.org> wrote:> > Thanks. > > I have made benchmarks and submited it here : http://dev.rubyonrails.org/ticket/9330 > > Looks like even FF profits from the Patch. > > About the unit tests, sadly i don''t use Ruby on Rails here, just PHP5 > with Prototype. > Started learning Ruby and Rails, but don''t have an usable environment > here at work. > > ~ Jan > > On Aug 21, 11:58 pm, "Martin Ström" <martinstromli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Looks promising. Try to submit a patch (howto @ > > <http://prototypejs.org/contribute>). I think the core team will be > > more interested if you provide benchmarks and unit tests as well. > > > > Ciao > > Martin > > > > -- > > burnfield.com/martin > > > > >-- burnfield.com/martin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---