On May 13, 6:12 pm, keemor <[email protected]> wrote:
> Hi,
>
> I'd like to present 3 ways of building ul list and compare the speed
> of them.
> I used firebug's profiler on FF3
>
> html:
> <body>
> <a href="#" id="go">go</a>
> <ul id="list"></ul>
> </body>
> $('go').observe('click',go);
>
[...]
> Third:
> Time to build (513.747ms, 30054 wywołań)
> function go(e){
> e.stop();
> var tpl = new Template ('<li class="#{class}" id="#{id}">#{id}</
> li>');
> var list = new String;
> $R(1, 1000).each(function(i){
> list += tpl.evaluate({class: 'klasa', id: i});
That line throws a parse error in Safari 4, class is a reserved word
in ECMAScript, use className.
> })
> $('list').update(list);
> }
>
> As you can see third method is 4 times faster than first one.
> In first two methods around 50% of time took
> extractScripts() & stripScripts() which are used in update and
> insert
> methods.
>
> So if you have more complex RIA with many dynamic elements you can
> simply improve it significantly :)
If speed matters, use plain javascript. Marginally more code, but the
result is 3 times faster in Firefox than "Third": (94ms vs 34ms in
Firefox 3 on a 1GHz G4) and twice as fast in Safari 4 (39ms vs 19ms).
--
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
-~----------~----~----~----~------~----~------~--~---