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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript, reduce blocking while loading XML

    Hi,

    I have been tasked with creating a JavaScript display engine for content located within a rather large XML file (22924 lines, 1.52 MB). Unfortunately I do not have control over the layout of this file.

    Currently I have written a custom object that is extended using prototype which converts the XML and allows for quick adding, filtering and sorting of the content based on various parameters; however the only thing currently slowing it down is the initial load of the XML data.

    To load the data, I am using jQuery to make it easy to traverse the XML data flow and then for each match it calls my custom object. This process takes 4 seconds on my machine and due to the way JavaScript works does full blocking - on a slower machine it has taken 10 seconds. Does anyone have any recommendations on how to possibly speed up this process or eliminate the blocking of the browser?

    Here is a quick example of the XML format:
    Code:
    <xml>
     <product name="XXXX1">
      <segment name="XXXX1_YYYY1">
       <plan name="XXXX1_YYYY1_ZZZZ1">
         <data name="content" />
         <data name="content" />
         <data name="content" />
        </plan>
       <plan name="XXXX1_YYYY1_ZZZZ2">
         <data name="content" />
         <data name="content" />
         <data name="content" />
        </plan>
      </segment>
      <segment name="XXXX1_YYYY2">
       <plan name="XXXX1_YYYY2_ZZZZ1">
         <data name="content" />
         <data name="content" />
        </plan>
      </segment>
     </product>
     <product name="XXXX2">
      <segment name="XXXX2_YYYY1">
       <plan name="XXXX2_YYYY1_ZZZZ1">
         <data name="content" />
        </plan>
      </segment>
     </product>
    </xml>
    Also as side-note - currently I only load a single product in at a time, to help speed things up - my next step may be to load in each segment at a time but this is a little more cumbersome as we need a single product loaded to be able to start.

    Any ideas or suggestions are appreciated!

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    301
    Thanks
    2
    Thanked 30 Times in 30 Posts
    At least as you've described it, there's no way to avoid loading the entire xml database in one shot. You can speed that up using deflate on the server side. Since it's a text file, it should reduce download. But this would really only show on dialup. Even the slowest DSL isn't going to slow much for a 1 meg file.

    As for handling in the browser, you're dependent on the xml libraries to parse the XML. I don't see how you can speed that up.

    As for searching, if you can sort the database and assume there are no duplicates, then you can write a simple binary search method. That will be quick.

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, the XML resides on the localhost - this is a desktop based JavaScript application. It's kind of hard to explain that situation, but in essence it's an IE7 container and has access to local files. Since the file loading is quick in this scenario, It's somewhat a benefit, but sadly also at a disadvantage since I can't do any external pre-processing on the XML to make it in a better structure to read in.

    The object itself is quick, but as you said, I am completely dependent on the browser libraries for parsing the XML so getting it in to the object is still my problem... oh well, guess this will do!

    Thanks for your insight..


  •  

    Tags for this Thread

    Posting Permissions

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