it reallly makes sense that it should be faster. When you do insertAdjacentHTML, that HTML has to be parsed by the browser which will end up doing document.createElement('DIV') etc anyway.

Benoit

On Friday, March 7, 2003, at 10:22 AM, Raymond Irving wrote:


--- Benoit Marchant <[EMAIL PROTECTED]> wrote:
If it looks like it's more efficient, and I remember
when we talked
about it in my test it was, we should certainly
fully test it and
eventually adopt it.

Yes I agree. We will still have to keep to old method to support ie4

--
Raymond Irving

Benoit

On Friday, March 7, 2003, at 07:16  AM, Raymond
Irving wrote:

Hi,

Some time ago benoit had suggested that we use the
createElement() function to create layers inside
DOM
browsers. After hitting my head against the wall
in
trying to prevent slow downs after with each newly
created layer, I've found the createElement()
function
to be more efficient than insertAdjacentHTML(). I
don't know how well this will scale with nested
layers, but I think it's a more efficient way to
go.

Please see the code below. Any comments?


Speed Test - 100 layers @ 170ms.

p._create = function() {
        if (this.parent && !this.elm) {                 
                DynElement._flagEvent(this,'precreate');                
                var elm, parentElement;
                parentElement = this.parent.elm;
                if(dynapi.ua.v<5){
                


parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML());
elm =


parentElement.children[parentElement.children.length-1];
                }
                else {
                        elm=document.createElement('DIV');
                        elm.id=this.id;
                        elm.style.position='absolute';
                        elm.style.pixelLeft=(this.x||0);
                        elm.style.pixelTop=(this.y||0);
                        elm.style.width=(this.w||'auto');
                        elm.style.height=(this.h||'auto');
                


elm.style.backgroundColor=(this.bgColor||'transparent');
                        elm.style.zIndex=(this.z||1);
                        elm.style.cursor=(this._cursor||'auto')
                        elm.style.overflow=(this._overflow!=null)?
'hidden;':'';                   
                        if(this.bgImage!=null)
elm.style.backgroundImage='url('+this.bgImage+')';
                        if (this.bgImage==null && this.html==null)
elm.style.backgroundImage='none';
                        if (this.clip)
elm.style.clip='rect('+this.clip[0]+'px
'+this.clip[1]+'px '+this.clip[2]+'px
'+this.clip[3]+'px)';
                        else if (this.w!=null && this.h!=null)
elm.style.clip='rect(0px '+this.w+'px '+this.h+'px
0px)';          
                        elm.style.visibility=(this.visible==false)?
'hidden':'inherit';
                        elm.innerHTML=this.getInnerHTML();
                        parentElement.appendChild(elm);
                }
                DynLayer._assignElement(this,elm);
                DynElement._flagEvent(this,'create');
        }
};


-- Raymond Irving

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/




-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers
of TotalView, The
debugger
for complex code. Debugging C/C++ programs can
leave you feeling lost
and
disoriented. TotalView can help you find your way.
Available on major
UNIX
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]


http://www.mail-archive.com/[EMAIL PROTECTED]/




__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/


-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
for complex code. Debugging C/C++ programs can leave you feeling lost and
disoriented. TotalView can help you find your way. Available on major UNIX
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://www.mail-archive.com/[EMAIL PROTECTED]/





------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://www.mail-archive.com/[EMAIL PROTECTED]/

Reply via email to