Page load delays

T

The alMIGHTY N

I have an XSL file that works with a typically large XML data set
generated dynamically from a database. This data is written to the
HTML result as a deep multi-dimensional array that is used by
Javascript functions to build large expanding/collapsing tables to
display the data.

The original developer wrote the page so that many writeln functions
were called in embedded Javascript to actually write the table as the
page was loading. This caused Javascript to throw a "script running
too long" error because the the scripts would have to wait for the
array to finish coming into existence.

I thought it an obvious solution to put an empty DIV on the page
first, wait for the page to finish loading, then use the BODY tag
onload call to run Javascript functions that would reference the
arrays and build the table through the DOM. The page still takes a bit
of time to load but there's a noticeable increase in the performance.

Recently, I decided that I needed to include some sort of "loading"
message so that users don't wonder why the page sits there blank for
several seconds. I included a Javascript function designed to hide the
message as soon as the DOM functions finished.

When I tested this, I found out that the message, contained within an
H1 tag placed well before the XSL started building the arrays, would
not load until the tables were drawn. At first, the message would
never show. After I removed the function to hide it, the message
appeared when the tables appeared.

My theory is that none of the HTML result is being rendered to the
screen until the XSL has completed loading everything... and that the
still significant delay is the result of the XSL loading versus the
DOM manipulation.

So my question is whether there's a way to force the H1 tag to appear
on the screen without having to wait for the XSL to finish parsing all
the data into the multi-dimensional array, which is much further down
in the HTML result.

Thank you for taking the time to read this far!

Nathaniel
 
J

Joe Kesselman

The said:
So my question is whether there's a way to force the H1 tag to appear
on the screen without having to wait for the XSL to finish parsing all
the data into the multi-dimensional array, which is much further down
in the HTML result.

That's a browser behavior issue, or perhaps a scripting issue, not an
XML/XSL issue. There's no reason a browser couldn't start showing the
page immediately and then correct it; the question is why your browser
has decided not to do so, whether there's any way to change its mind,
and whether that solution is at all portable.

The traditional HTML solution, of course, would be to divide the problem
-- move the array into a separately loaded document.
 
T

The alMIGHTY N

That's a browser behavior issue, or perhaps a scripting issue, not an
XML/XSL issue. There's no reason a browser couldn't start showing the
page immediately and then correct it;

If the XML document is really big, wouldn't that cause some sort of
delay in the loading of the page?

XML needs to be well-formed, right? How would the parser verify the
document is well-formed if it doesn't go through the whole thing
first?

My thought was that first the browser gets the XSL file, which in turn
gets the XML document. The XML document is big so it has to load all
of that first, then it goes through and runs the XSL transformations
on it. Part of those transformations include building the Javascript
array.

Once it loads up the whole XML document and verifies that it's well-
formed, it can start displaying the page as the XSL performs its
transformations.

I don't think it's getting caught on the XSL... I think it's getting
caught on loading the XML.

Of course, I'm not even close to an expert on XML or XSL so I may not
have an understanding of how it all works.
 
J

Joe Kesselman

The said:
If the XML document is really big, wouldn't that cause some sort of
delay in the loading of the page?

Depends on how it's being processed.
XML needs to be well-formed, right? How would the parser verify the
document is well-formed if it doesn't go through the whole thing
first?

Depends on how it's being processed. The application could begin
rendering, then stop and flag an error when the problem is encountered,
and recover in some reasonable way. This is an application design issue,
and in your case involves details of exactly how the XSLT processor and
browser have been written and configured.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top