Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15387

Re: How to improve performance growing this <li>

From "Richard Maher" <maher_rj@hotspamnotmail.com>
Newsgroups comp.lang.javascript
Subject Re: How to improve performance growing this <li>
Date 2012-08-18 06:18 +0800
Organization HTTP *is* The Box - Let's think outside
Message-ID <k0mfur$2o6$1@speranza.aioe.org> (permalink)
References <k0l3jr$qbu$1@speranza.aioe.org> <k0l3nh$qhe$1@speranza.aioe.org> <afas28dkk284q30s2gh9tacq25ptjjo9pu@4ax.com>

Show all headers | View raw


<Dr.Kral@nyc.rr.com> wrote in message
news:afas28dkk284q30s2gh9tacq25ptjjo9pu@4ax.com...
> On Fri, 17 Aug 2012 17:43:13 +0800, "Richard Maher"
> <maher_rj@hotspamnotmail.com> wrote in <k0l3nh$qhe$1@speranza.aioe.org>:
>
>>Hope this formats better: -
> It didn't

Hopefully this time?

>
> On Fri, 17 Aug 2012 17:41:15 +0800, "Richard Maher"
> <maher_rj@hotspamnotmail.com> wrote in <k0l3jr$qbu$1@speranza.aioe.org>:
>
>>Hi,
>>
>>I'm trying to grow/extend a list <li> using the DOM routines and it
>>performs
>>badly. Once your over 100 rows performance degrades and 3000 rows on IE8
>>takes 40secs to render and FF just under 10secs. (Yes 3000 is a lot but
>>with
>>the scroll-bar on the <div> it is still useful to the user and even if I
>>set
>>a max limit on result-set rows I'd still like to improve performance!)
>
> Without knowing internal details of how things are rendered I will suggest
> that each time you add an element the page is re-rendered.  If this is the
> case, then the time would go up faster than the square of the number of
> elements added.  There is a similar sort of behavior with some string
> operations that effectively have to copy the entire string thus taking a
> long time.
>
> If this hypothesis is correct, then you want to find a way to add many
> items at one time.  Perhaps just changing the innerHTML of the division?
>
> HTH

Thanks for the reply.

The problem I have with innerHTML is how to add my "_key" property to each 
<li> as in "listItem._key = rowKey;" below. (Also I thought it might be 
useful for the user to see the scrollbar grow (shrink) in the <div> but that 
does not seem to be observable anyway)


var getLOV =
        function () {
            var lovVintage = ++currVintage;
            var rowCnt = 0;
            targetDiv.style.height = "0px";
            targetDiv.style.visibility = "hidden";
            return function (rowKey, rowData) {
                if (lovVintage != currVintage)
                    return;

                var listItem = document.createElement("li");
                var listData = document.createTextNode(rowData.rTrim());

                listItem.appendChild(listData);
                listItem._key = rowKey;

                suggestList.appendChild(listItem);
                rowCnt++;

                if (rowCnt == 1) {
                    targetDiv.style.height = "auto";
                    targetDiv.style.visibility = "visible";
                }

                if (rowCnt == lovMax)
                    targetDiv.style.height = targetDiv.clientHeight + "px";

                if (targetDiv.clientWidth < targetDiv.scrollWidth)
                    targetDiv.style.width = (targetDiv.scrollWidth
                                           + (targetDiv.scrollWidth - 
targetDiv.clientWidth)) + "px";
            }
        }


Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to improve performance growing this <li> "Richard Maher" <maher_rj@hotspamnotmail.com> - 2012-08-17 17:41 +0800
  Re: How to improve performance growing this <li> "Richard Maher" <maher_rj@hotspamnotmail.com> - 2012-08-17 17:43 +0800
    Re: How to improve performance growing this <li> Dr.Kral@nyc.rr.com - 2012-08-17 07:27 -0400
      Re: How to improve performance growing this <li> "Richard Maher" <maher_rj@hotspamnotmail.com> - 2012-08-18 06:18 +0800
      Re: How to improve performance growing this <li> Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-17 23:16 +0000
        Re: How to improve performance growing this <li> Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-18 00:33 +0000
          Re: How to improve performance growing this <li> Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-18 11:05 +0000
            Re: How to improve performance growing this <li> SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-18 16:57 +0200
              Re: How to improve performance growing this <li> Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-18 16:23 +0000
                Re: How to improve performance growing this <li> Dr J R Stockton <reply1233@merlyn.demon.co.uk.invalid> - 2012-08-19 20:16 +0100
                Re: How to improve performance growing this <li> SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-20 12:29 +0200
                Re: How to improve performance growing this <li> Dr J R Stockton <reply1234@merlyn.demon.co.uk.invalid> - 2012-08-21 20:44 +0100

csiph-web