William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

Smarty: HTML comment and net traffic

Smarty: HTML comment

Sometimes when modifying HTML files, we are accustomed to using HTML comment “<!– –> to temporarily comment some codes, in case of later reuse.
To do this in Smarty templates file need to be very careful, because the comment codes might cause bad results. Like the following:

{Smarty comment: The following HTML comment is not SAFE and harmful!}
<!--div id="div_list"> {include file="{$template}"} </div-->

The above statement will cause very big leak: instead of ignoring this statement, Smarty actually parses and executes this statement, fills up HTML with file {$templates}, and finally, comment them with <!–, –>!
e.g.: the Smarty {$template} generates 1000 lines output, then use <!– –> to comment them, hide the output. This largely decreases the script performance.
Put the comment here is very bad: cause network traffic, and decrease the performance.
This might be a bug of Smarty, and should not happen when HTML has already comment the statement. However it does.

The solution:
Just remove it, to make codes clean.


2 responses to “Smarty: HTML comment and net traffic

  1. peter 10/17/2011 at 8:46 am

    Nice Blog. I kind a like it very much.Very useful Information. Will come to your website again.

    Nice greetings from Austria


  2. powercashadvance.com 10/28/2011 at 11:02 am

    What would most people do without the magnificent suggestions you write about on this web site? Who has got the fortitude to deal with important topics just for common visitors like me? My spouse and i and my pals are very happy to have your blog among the types we usually visit. Hopefully you know how a great deal we get pleasure from your work! Best wishes coming from us all.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: