X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Smarty.php Mod to Remove all UN-NECESSARY White Space (https://forum.x-cart.com/showthread.php?t=7920)

Adian009 06-04-2004 09:40 PM

Smarty.php Mod to Remove all UN-NECESSARY White Space
Smarty has an included filter that you can implement quite simply by adding one line of code to your SMARTY.PHP file.

Add the following line to the file just below the ImagesDir and SkinDir assign statements near the end:



It safely removes all whitespace from the generated HTML just prior to sending the page to the client - increases speed dramatically by reducing the overall size of the file. It works great and you will have no more un-necessary blank lines or spaces.

Check it out before and after by using View, Source in your browser on any X-Cart page - the difference is easily noticable.

Al Ponte

TelaFirma 06-05-2004 04:56 AM

Have you tested this will all the JavaScript that is in X-Cart? Some JS does not function wel after removing whitespace....

TelaFirma 06-05-2004 05:01 AM

Ok... I see... it is actually leaving the Javascript alone. Much different than {strip} tags. Interesting....

B00MER 06-08-2004 12:42 PM

Nifty trick, tested it with 3.5.x works like a charm. You know what version this was added to smarty :?:

FX 06-10-2004 07:42 PM

Thanks Adian009,
Works great in 3.5.8! Before I had 417 lines of code in one of my pages, now I have 404 :wink:
I was looking for this function, even wanted to use external editor.

carlisleglass 06-10-2004 11:37 PM

Very good discovery !! Its speeded up my site

PhilJ 06-11-2004 03:28 AM

Did anyone find that it stripped out the spaces in the e-mail templates too?

NuAlpha 06-12-2004 09:28 AM


Originally Posted by PhilJ
Did anyone find that it stripped out the spaces in the e-mail templates too?

Anyone know if there is a way to prevent this by perhaps putting certain tags in the email templates that prevent them from having the spaces stripped out?

One problem I found with using {strip} tags is that two Smarty tags with a space between them will be butted up against each other, and so to maintain the spacing I had to put "" between them.

Does this problem happen with this Smarty modification? :?

Adian009 06-12-2004 02:57 PM

Replies to All
Well, you use {literal}{/literal} with JavaScript and it won't be touched. I have been using this for 3 months without issue.

This will only strip whitespace from templates being sent to a client - not email as far as I know.


NuAlpha 06-12-2004 07:42 PM

Some email templates are used for display in the browser.

I guess I will just stick with adding {strip} tags to various documents until I get this worked out.

All times are GMT -8. The time now is 01:35 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.