I have a large "grid" of data that takes about 40 seconds to generate and dump as plain text. If I wrap the text with html table formatting (with fixed td widths) it takes over 200 seconds to completely display in IE7, and under a minute to display in Safari. Small "grids" display in under 5 seconds in either browser, so I don't think it's related to anything other than data volume. Is there anything I can do on the server side to speed up IE7 display? Telling the users to stop banging their heads against the wall is not an option.
问题:
回答1:
Set the css attribute for table-layout: fixed on the table. IE will then not have to recompute the table size for each additional row / column that's added and it will speed up dramatically.
BTW, the w3schools link has some good info about this.
table-layout takes one of three values: auto, fixed, and inherit.
auto is the default. The browser has to load the entire table before it can compute the sizes and start rendering. This ranges from slow to very slow depending on the rendering engine of the browser.
fixed. The first row defines the width of the columns. Because of this the browser can render content as it's downloading. Hence the speed increase. As a minor side note, because all width's other than the top row are ignored, you don't have to send the width data down for remaining columns... Which means your page size can be a bit smaller.
inherit. Basically, get it's value from the parent.
回答2:
Even the Safari "under a minute" seems unbearable. Wherever I have anything that slow I put up a progress bar and some stats about the data.
Kazar's pagination idea may be the way to go, or progressive loading as Oscar Reyes suggests.
Just how many rows and columns is this data that it takes that long?
回答3:
I'm sorry, but IE7 is just an old browser, and thus isn't quite as fast as Safari...they might see some performance increase if they upgraded to IE8, or Firefox, or Chrome...
回答4:
Perhaps paginate the grid, probably will make it more readable, and faster on both browsers?
回答5:
Why is IE7 so slow compared to Safari?
Because they have different HTML engines, that work differently, different algorithms, different etc's
Is there anything I can do on the server side to speed up IE7 display?
Perhaps you could try using Ajax. That way the perceived speed will be much better.
回答6:
Since you're programmatically generating this data anyway, you might try using <pre> tag which will display the text in a monospaced font. This way, you can quickly calculate cell width and height yourself. It won't look the prettiest, but it will avoid any layout time.
If you don't want to do this by hand, and you have no links in your table, you can use the elinks web browser to render the HTML to plain text and place that output in <pre> tags.
elinks -dump ./localfile.html
On a secondary note, if you haven't already, you should insure that you are gzipping the data on the server side, so that transfer time is reduced. For IIS, instructions to enable gzipping can be found here. For Apache, instructions to enable mod_gzip can be found here. For Apache, try Apache's own documentation on mod_deflate.
回答7:
These are all great suggestions - but I found the smoking gun! When IE renders the page, a process called Mcshield.exe takes over the machine. Since the server is on the same box, it slows the page generation as well as the rendering. Now the question is "why does McAfee crush IE and not Safari?" - and I'll research that one. Thanks again Stack Overflow!