Optimized HTML (after).

Power Java
Techniques for Optimizing Web Site Development and Runtime Characteristics

Christopher A. Fregly
Listing 10. Optimized HTML (after).

function loadRow( specialFlag, lineNumber, description, brand,
                                             casePrice, eachPrice ){
	document.write( '<tr>' );
	document.write( '<td bgcolor="red" width="37"
align="center">' + specialFlag + '<br></td>' );
	document.write( '<td bgcolor="red" width="24"
align="center"><font face="Verdana, Arial, Helvetica, sans-serif">' +
                                             lineNumber + '</font></td>' );
	document.write( '<td bgcolor="red" align="left"
width="240"><font face="Verdana, Arial, Helvetica, sans-serif"
size="1" color="#000000">' + description + '</font></TD>' );
	document.write( '<td bgcolor="red" width="55" ><font
face="Verdana, Arial, Helvetica, sans-serif">' + brand +
	document.write( '<td bgcolor="red" width="58" ><font
face="Verdana, Arial, Helvetica, sans-serif" size="1">' + casePrice +
                                                            '</font></td>' );
	document.write( '<td bgcolor="red" align="RIGHT"
width="65"><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">' + eachPrice + '</font></td>' );
	document.write( '</tr>' );

loadRow('Special','Line 1','Canned Peas(15928)','BrandX','3.97','1.97');
<!- 62 chars repeated * 1,000 rows = 62,000 chars = approx. 90%
reduction in size ->

About the Author

Christopher A. Fregly is Senior Cunsultant for BEA Systems Inc. in Chicago. He can be contacted at chris@fregly.