Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
In general, I settled on a simple and banaltrim(preg_replace('/\s+/', ' ', $html))
If you use Smarty as a template engine, then there is a special tag {strip} , inside which html is minified, and plus, this happens only once during template compilation, and not with every request.
As for the standard tools, try adapting a widget from Yii2 that deals with cutting out unnecessary gaps - Spaceless .
if the pages are generated by yii itself, then hang the behavior on this event
YII1 www.yiiframework.com/doc/api/1.1/CController#after... that
removes spaces from the view
, the function itself can be peeped in the widget mentioned above
public function minify(string $content):string
{
return trim(preg_replace('/>\s+</', '><', $content));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question