I just did some tests, just to show the differences between.

time to insert 10,000 span with hello + i
KONQUEROR:
concated string method: 3614ms
 insertion every iteration: 62510 ms

FIREFOX 2:
concated string method: 574ms
 insertion every iteration: 71924ms

I haven't tested this on Opera, Safari, IE, but I bet the results will
be similary out-disreportional. And I know 10,000 elements is extreme,
but to be honest some people iterate quite a few elements...

Here is my method of testing...

var i = 10000, content = '';

//FIRST TEST CONCATED STRINGS
var start = date.getTime();
document.body.update('');
while(i)
{
content += '<span>hello' + i + '</span>';
i--;
}
document.body.insert(content);
var end = new Date();

//SECOND TEST INSERTION EVERY ITERATION
var start = new Date();
document.body.update('');
while(i)
{
document.body.insert('<span>hello' + i + '</span>');
i--;
}
var end = new Date()
alert((end - start));

I don't want to annoy anyone on this, but it just strenghens why I
needed to concate the elements, which is causing my problems...

On Nov 4, 2:44 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I have been trying to figure out a way that I can insert multiple
> elements into the document, without having to use the
> Element.insertion method every time which obviously isn't an efficient
> way to do it. Therefore I had to create an element in string (html
> form) and then concate  them togetether and then insert it which is
> much faster.
>
> The problem is this doesn't allow me to retrieve the element for later
> use later, which up to now wasn't a problem. So I have been messing
> around with the Element Builder, which isn't useful for me. The fact
> that you cannot create an element from a html source isn't helping me.
>
> To conclude, one suggestion that I have for the future is a way to
> insert multiple Elements using an array argument for the insertion
> method, or make another method for creating a new element from a html
> source string.
>
> I may be wrong in this, but at the moment I cannot think of a better
> way around this, perhaps there is a solution I haven't thought about.
> Another thought that just come to me now is, whether there isn't an
> actual deficiency in your insertion methods, because doesn't it using
> native Dom methods to insert an element?
>
> Thanks for your time to answer this.
>
> Luke Parry


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to