faster page loading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Soniad
    New Member
    • Jan 2009
    • 66

    #1

    faster page loading

    Hello,
    i am using VBScript to load xml file and creating array of xml child nodes. i am retreiving this xml file from server using "Server.mappath ". i think due to this process, my asp page is loading slowly. i want to reduce page load time..any suggestions..

    Regards,
    "D"
  • Nicodemas
    Recognized Expert New Member
    • Nov 2007
    • 164

    #2
    I can't agree that use of Server.MapPath( ) is the cause of the execution time lag.

    Can we see some code?

    Comment

    • Soniad
      New Member
      • Jan 2009
      • 66

      #3
      faster page loading

      ya sure..here's the code :


      If trim(session("l anguage")) = "" Then
      session("langua ge") = "ENGLISH"
      End If
      Dim xml
      Set xml = Server.CreateOb ject("Microsoft .XMLDOM")
      xml.async = False 'Download XML file first, then load rest of page (IE only)

      xml.load (Server.MapPath ("../../language/"&trim(session( "language") )&"/Instant.xml"))


      For i = 0 TO (xml.documentEl ement.childNode s.length - 1)
      Set thisChild = xml.documentEle ment.childNodes (i)
      English = thisChild.child Nodes(2).Text
      ReDim Preserve hindiArray(i)
      hindiArray(i) = English
      next


      xml.async = False '//Download XML file first, then load rest of page (IE only)

      xml.load (Server.MapPath ("../../language/"&trim(session( "language") )&"/common.xml"))

      For i = 0 TO (xml.documentEl ement.childNode s.length - 1)
      Set thisChild = xml.documentEle ment.childNodes (i)
      English= thisChild.child Nodes(2).Text
      ReDim Preserve CmhindiArray(i)
      CmhindiArray(i) = English
      Next


      set xml = Nothing



      Regards
      "D"

      Comment

      • Nicodemas
        Recognized Expert New Member
        • Nov 2007
        • 164

        #4
        the issue is in your For loop, I believe. My reasons are below, as well as my suggestions:

        Change your For loop's counting method. You have this:
        Code:
        For i = 0 TO (xml.documentElement.childNodes.length - 1)
        Everytime the loop cycles back, it has to reevaluate the value of xml.documentEle ment.childNodes .length - 1. Instead of making the processor do that math over and over again, do the following. It's only one computation:

        Code:
        dim stopCount
        stopCount = xml.documentElement.childNodes.length - 1
        
        For i = 0 to stopCount

        Second, you have a ReDim statement in your loop. That's really processor intensive because it has to reassign the entire memory space of the array each time you ReDim.

        I suggest you use a VBScript dictionary instead.

        Comment

        • Soniad
          New Member
          • Jan 2009
          • 66

          #5
          faster page loading

          Originally posted by Nicodemas
          the issue is in your For loop, I believe. My reasons are below, as well as my suggestions:

          Change your For loop's counting method. You have this:
          Code:
          For i = 0 TO (xml.documentElement.childNodes.length - 1)
          Everytime the loop cycles back, it has to reevaluate the value of xml.documentEle ment.childNodes .length - 1. Instead of making the processor do that math over and over again, do the following. It's only one computation:

          Code:
          dim stopCount
          stopCount = xml.documentElement.childNodes.length - 1
          
          For i = 0 to stopCount

          Second, you have a ReDim statement in your loop. That's really processor intensive because it has to reassign the entire memory space of the array each time you ReDim.

          I suggest you use a VBScript dictionary instead.

          Thank you ...I have modified the code as below ..and its loading time is much better than before..


          Code:
          stopCount = xml.documentElement.childNodes.length - 1 				
          ReDim Preserve hindiArray(stopCount)
          	
          For i = 0 TO stopCount
          	Set thisChild = xml.documentElement.childNodes(i) 
          	English = thisChild.childNodes(2).Text 
          	'ReDim Preserve hindiArray(i)
          	hindiArray(i) = English
          next

          Regards,
          "D"

          Comment

          Working...