summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2020-07-14 14:15:59 +0800
committerBigCoke233 <hi@guhub.cn>2020-07-14 14:15:59 +0800
commitd75331d8b8816f0806ca324b550483cbadaf656f (patch)
tree804ff5f554ac0917a3abde0e9526466da508e0d2 /includes
parent5690f8c59778373553a2a4b96b18900cc41d13b4 (diff)
:zap: Add: 加入 HTML 压缩功能
Diffstat (limited to 'includes')
-rw-r--r--includes/footer.php14
-rw-r--r--includes/head.php3
2 files changed, 11 insertions, 6 deletions
diff --git a/includes/footer.php b/includes/footer.php
index 312249e..82d39dc 100644
--- a/includes/footer.php
+++ b/includes/footer.php
@@ -12,7 +12,7 @@
$faces = explode("&&",$faces);
$faces = "<span class=\"anime-face\">".$faces[mt_rand(0,count($faces)-1)]."</span>";
}
- if($faces && $this->options->build_time)echo $faces;
+ if($faces && $this->options->build_time) echo $faces;
?></p>
</div>
</footer>
@@ -26,7 +26,7 @@
if($this->options->customCDN): $custom=$this->options->customCDN; else: $custom=Helper::options()->themeUrl("","Miracles"); endif;
Utils::addRequires($js_files,"js",$this->options->CDN,$custom);
?>
- <!-- Options -->
+ <!-- Options --><!--<nocompress>-->
<script>var navSlide = <?php if($this->options->navSlide==1):?>false<?php else:?>true<?php endif;?>;
var panguLoadAllow = <?php if($this->options->pangu==1):?>false<?php else:?>true<?php endif;?>;
var allowNavAero = <?php if($this->options->navAero==1):?>false<?php else:?>true<?php endif;?>;
@@ -37,7 +37,7 @@
if($faviconDarkExist=true): echo 'true'; else: echo 'false'; endif; ?>;
<?php if($this->options->pjax && $this->options->pjax!=0) :?>var loadPjax = true;
beforePjax = function() {NProgress.start();};
- afterPjax = function() {owoLoad();<?php $this->options->pjax_complete(); ?>};<?php endif; ?></script>
+ afterPjax = function() {owoLoad();<?php $this->options->pjax_complete(); ?>};<?php endif; ?></script><!--</nocompress>-->
<!-- Script that must be after-->
<?php
$js_files=array("miracles.min","cmt.miracles");
@@ -45,15 +45,19 @@
Utils::addRequires($js_files,"js",$this->options->CDN,$custom);
?>
<!-- JavaScript -->
- <script>
+ <!--<nocompress>--><script>
<?php if($this->options->build_time)echo "startTime(\"".$this->options->build_time."\");" ?>
- </script>
+ </script><!--</nocompress>-->
<!-- Send News and Loaders -->
<script><?php if($this->is('post') || $this->is('page')): ?>owoLoad();<?php endif; ?><?php $this->options->jsEcho(); ?></script>
<!-- Others -->
<?php $this->footer(); ?>
</body>
</html>
+<?php if($GLOBALS['miraclesIfCompressHTML']=='on') {
+ $html_source = ob_get_contents(); //获取 ob 截取内容
+ ob_clean(); print Utils::compressHtml($html_source); ob_end_flush(); //完成截取、压缩 HTML
+} ?>
<!--
Powered by Typecho,
diff --git a/includes/head.php b/includes/head.php
index 3a6aa92..41f143d 100644
--- a/includes/head.php
+++ b/includes/head.php
@@ -1,4 +1,5 @@
-<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
+<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit;
+if($GLOBALS['miraclesIfCompressHTML']=='on') ob_start(); //ob 截取开始 ?>
<!DOCTYPE HTML>
<html<?php if($this->options->grayTheme && $this->options->grayTheme=1): ?> class="html-filter-gray"<?php endif; ?>>
<head>