Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Efficiency Question

    Hi,

    In this scrollable list table here (http://96.57.154.180), if you do a partial lookup, or type and submit "all" a big list gets generated and for some reason it works really fast in chrome and firefox, but works really slow in Internet Explorer.

    If you just take a glimpse, because it's all written in amateur javascript, do you notice anything terribly inefficient that I could change to maybe speed up the onmousemove refresh? What do you think in general about this approach to displaying large quantities of data at once?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,461
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    http://96.57.154.180/ezgen/
    Service Temporarily Unavailable

    Let us know when it's working again.

    FWIW, MSIE *is* much slower in many many things than FF or Chrome.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,335
    Thanks
    11
    Thanked 588 Times in 569 Posts
    Code:
    for (var j = 0; j < searchTitle.length; j++) {
    could be

    Code:
    for (var j = 0, mx= searchTitle.length; j <mx; j++) {
    should boost ie about 30% compared to an unbuffered length cap.
    i don't know how much it will help your app since i don't debug IE for free, but it tends to...


    also, String(i) + String(5) could be slightly faster by using i+""+5, since it avoids extra function calls.

    that's what popped out at me at a glance, you can have your money back if it doesn't help
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #4
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I understand that Chrome and FF run javascript more smoothly in general.

    I was however able to gain an improvement by consolidating variable declarations inside the script tag at the top of the body, rather than having them declared inside of functions or events located more in the center, but it seems like it can run faster without too much overhauling.
    Last edited by pneeko; 08-30-2010 at 09:16 PM.

  • #5
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry for recirculating an old thread, but I put it back up again, so an inquiry will generate the scrollable list table I would just like to know if there's something I can do to tweak my code in IE to get more refreshes on events, particularly the document.mousemove event. I don't have errors at the moment, just possibly a design flaw.

    I'm trying to display thousands of pieces of selectable data with one page load without a lot of overhead. Is there a more practical way of doing this without browser addons/modules?

    It seems inconvenient to have to click on "display 1-20" or "50-60" or "120-140", or waiting for the server to respond with Ajax (in the few applications I've seen) when instead you can see all 5000 in one shot.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,461
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    How about this?

    Show the first 100 immediately.

    Then, behind the scenes, use AJAX to load the other 4900. By the time the user has stared at the page for a few seconds and realizes he/she really wants to see 1733, it will be there.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    How about this?

    Show the first 100 immediately.

    Then, behind the scenes, use AJAX to load the other 4900. By the time the user has stared at the page for a few seconds and realizes he/she really wants to see 1733, it will be there.
    I would gladly try that, but even with just 200 rows of data, the scrolling in IE is still slow.

    The data for each column is loaded into an array of literals, and a fixed table of divs. Each time the scroll slider goes up or down, the divs get updated to the correct position in the literal array using a for loop.

    data = new Array(9);

    data = ["data1", "data2", ...];

    div[3] = new div (gets instantiated in the js file);
    data1
    data2
    data3 div 1
    data4 div 2
    data5 div 3
    data6
    data7
    data8
    data9
    ...


    scroll down and all that happens is


    data1
    data2
    data3
    data4
    data5
    data6 div1
    data7 div2
    data8 div3
    data9
    ...
    Last edited by pneeko; 09-01-2010 at 08:38 PM.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,461
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    Got me, then. Something you are doing is just busting IE's bubble. Hard to believe it can't scroll 200 items fast enough.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •