Optimized generation of HTML