Program | speed
1. Use table nesting?
Create complex structures in a page, typically by placing HTML tables in the page. If you want to create a page like this: This page has a top navigation bar, a left navigation bar, and a content area to the right. You can use a two-row, two-column large table to build it. In the first row, merge two columns, and then insert a top navigation bar. In the column to the left of the second row, insert a table to display the navigation buttons. In the right column, place a table for the actual content. (See figure I) The code generated by this nested table is this:
However, in fact, when a browser finds a
label, it does not immediately display the page to the screen unless it finds the appropriate closing tag
. So, if your entire page is in a table, nothing will be displayed until the last is received, so that the page will be visible to the user after the entire file has been downloaded. This feature can cause a temporary pause when the volume of page data is larger (such as search results for search engines). To prevent this from happening, you can divide the page into small tables when you make it. At the end of each HTML code that is
section, the browser displays it. In the view of the visitor, the page is gradually, some part, more and more appear on the screen. Feeling, such a page display faster than downloading the entire file again.
By using this principle to study the previous example, you should divide the entire large table in the page into three separate tables. Use the first table to display the top navigation bar, adjust its width so that it holds all the content, and complete it in a
code snippet. The bottom half of the page, and the second table on the left is lined with a column. Use a third table to accommodate the actual content. (see figure II) because each part is a complete table, each part of the code is immediately displayed when it is downloaded. This way, the top and left navigation bars will show more than the rest of the page. At this point the user imagines that the page will start downloading and will soon be displayed on the screen. This is much better than allowing the user to face a blank screen for a long time.
The modified code is like this:
2. Also remember to close other tags
In the example above, we just close the
tag earlier and make the page appear faster in the browser. And so on, there are some similar tags that have the same characteristics.
For example, create list boxes and combo boxes to mark and generate list items
tags. Typically, an ASP programmer accesses the database and feeds the data into a list box or combo box created by , and then writes a close tag in the code, so that simple changes can also make the page appear faster in the browser.
Do not use such a code:
Do as Not objrs.eof
Stroptionlist = stroptionlist & "" & _objrs ("ProductName")
Objrs.movenext
Loop
Response.Write "" & Stroptionlist & ""
To use this code:
Do as Not objrs.eof
Stroptionlist = stroptionlist & ""
Objrs.movenext
Loop
Response.Write "" & Stroptionlist & ""
Do not use such a code:
Use this code:
Now look, does your page appear fast in the browser?
Please do not underestimate the importance of these changes to improve the performance of ASP programs. Perhaps, in a book or online material that you can find "tips and hints," there is little mention of optimizing HTML code to make your program run faster. However, in the actual application of these technologies, it is true that the program performance can be greatly improved.