Skip to content

Commit cc81387

Browse files
committed
Update SpeedOptimizer.php
Fixed error sometime return blank page if html not stand or missing tag.
1 parent 81fd2e4 commit cc81387

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Plugin/SpeedOptimizer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: nguyen
44
* @Date: 2020-02-12 14:01:01
55
* @Last Modified by: Alex Dong
6-
* @Last Modified time: 2020-05-21 15:07:46
6+
* @Last Modified time: 2020-11-06 14:06:27
77
*/
88

99
namespace Magepow\SpeedOptimizer\Plugin;
@@ -320,7 +320,9 @@ public function minifyJs($script)
320320
'',
321321
'\\1',
322322
);
323-
return preg_replace($search, $replace, $script);
323+
$minScript = preg_replace($search, $replace, $script);
324+
/* Return $script when $minScript empty */
325+
return $minScript ? $minScript : $script;
324326
}
325327

326328
public function minifyHtml($content)
@@ -341,7 +343,9 @@ public function minifyHtml($content)
341343
// ''
342344
);
343345

344-
return preg_replace($search, $replace, $content);
346+
$minHtml = preg_replace($search, $replace, $content);
347+
/* Return $content when $minHtml empty */
348+
return $minHtml ? $minHtml : $content;
345349
}
346350

347351
public function addLoading($content)

0 commit comments

Comments
 (0)