The present invention is directed towards providing a system and method
for optimizing HTML output in a just-in-time compiling environment for
devices such as mobile devices. A method is provided for optimizing the
output in a single pass as device content is rendered. The method delays
writing a closing tag until it is determined that a formatting or layout
of the next control conflicts. Tags are emitted in a predefined order to
minimize the number of tags that will need to be closed to accommodate a
following control whose style differs. Object hierarchy is leveraged to
predict the order in which tags should be written without looking ahead
of the current control in the hierarchy.