optimize output html code


I came to the head, to optimize the HTML code generated by Yii. For example, removing extra spaces, blank lines, code format.

Does this makes sense and can affect a performance?

How do something like that?

Yes, it makes sense. You can achieve this by writing an action filter (you can refer to CHtmlPurifier).

Regarding white space stripping. This has been discussed before elsewhere on the internet and the conclusion generally is that it's not worth it. On big pages it can be quite an overhead whilsts gzipping the page generally accomplishes the same thing sizewise.

Code formatting will also be quite resource intensive I assume, so handling this with php will again be quite an overhead. A php extension such as tidy might be better suited for this.