View previous topic :: View next topic |
Author |
Message |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Fri Mar 20, 2009 4:26 pm Post subject: Compress! Compress!! Compress!!! |
|
|
Visit first: http://developer.yahoo.com/performance/rules.html
Please read the above URL, because that is great, over my few comments below:
$marty's {strip} ... {/strip} plugin has a very nice compression feature. Since Unnecessary white-spaces (Tabs, New lines and Spaces) in the HTML output is really useless, remove them.
Even if code formatting is recommended, that has no use other than letting people steal your data easily. Many Search engines should have used Regular Expressions and whatever tight codes you write (ideally, that without white spaces), it still should become SEO friendly.
Search engines don't just limit to your code formatting to index information in your web pages!
So, with Smarty, you can write clean templates but compressed HTML output. Enjoy serving lesser HTML. Do not just send white spaces spams to the browsers!
How is the idea?
Last edited by bimal on Fri Apr 03, 2009 4:25 am; edited 1 time in total |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 20, 2009 4:51 pm Post subject: |
|
|
You can shorten up all of your html with the trimwhitespace output filter. |
|
Back to top |
|
rustybucket Smarty Regular
Joined: 28 Jan 2009 Posts: 60
|
Posted: Thu Apr 02, 2009 7:43 pm Post subject: |
|
|
You are the MAN Bimal! I've been through the docs now a couple of times and never noticed this!
Thanks! |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
|
Back to top |
|
chishikinohito Smarty Regular
Joined: 29 Nov 2010 Posts: 54
|
Posted: Tue Dec 09, 2014 12:32 pm Post subject: Thanks, this is nice |
|
|
It's really cool to out put everything as single line rather than structured content.
Is anybody aware if it's possible to refrain from doing it in every template though?
I would rather put it once on the very top, in `header.tpl` and in the very bottom, in `footer.tpl`.
It seems that Smarty tags are not transferred through the templates?
Is there a safe work around? |
|
Back to top |
|
prophet Smarty n00b
Joined: 09 Dec 2014 Posts: 3
|
Posted: Tue Dec 09, 2014 1:53 pm Post subject: Re: Thanks, this is nice |
|
|
chishikinohito wrote: | It's really cool to out put everything as single line rather than structured content.
Is anybody aware if it's possible to refrain from doing it in every template though?
I would rather put it once on the very top, in `header.tpl` and in the very bottom, in `footer.tpl`.
It seems that Smarty tags are not transferred through the templates?
Is there a safe work around? |
+1 to this question. It's quite annoying to have to remember to put {strip} tags inside each small template. Would rather enable it globally, or, at least, in the header and footer tags to do it everywhere in between. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Dec 09, 2014 3:34 pm Post subject: |
|
|
You could create an output filter that modifies the output text. This would apply to all templates inclusive to a display() or fetch() call. |
|
Back to top |
|
chishikinohito Smarty Regular
Joined: 29 Nov 2010 Posts: 54
|
Posted: Tue Dec 09, 2014 6:36 pm Post subject: |
|
|
How do you use it with display or fetch, could you give it an example please? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Dec 09, 2014 11:38 pm Post subject: |
|
|
Just create and register an output filter.
Then it will be applied automatically, when you call Smarty::display or Smarty::fetch |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Dec 10, 2014 12:43 am Post subject: |
|
|
You may try
Code: | $smarty->loadFilter('output', 'trimwhitespace'); |
which does exists in the plugins folder. |
|
Back to top |
|
chishikinohito Smarty Regular
Joined: 29 Nov 2010 Posts: 54
|
Posted: Wed Dec 10, 2014 7:03 am Post subject: |
|
|
Thank you, that is really fast-forward solution! |
|
Back to top |
|
|