Add new Performance API's to October CMS (#4285)
PR adds a new Priority Hints API, Preload API and async to the October CMS AJAX injected code and a new Priority Hints API to the loaded assets in the head section. Credit to @ayumihamsaki. Related #4277, #4030
This commit is contained in:
parent
46c867e4b5
commit
f4e50ddd1a
|
|
@ -30,13 +30,13 @@
|
|||
?>
|
||||
|
||||
<?php foreach ($styles as $style) : ?>
|
||||
<link href="<?= $style . '?v=' . $coreBuild; ?>" rel="stylesheet">
|
||||
<link href="<?= $style . '?v=' . $coreBuild; ?>" rel="preload" as="style">
|
||||
<link href="<?= $style . '?v=' . $coreBuild; ?>" rel="stylesheet" importance="high">
|
||||
<link href="<?= $style . '?v=' . $coreBuild; ?>" rel="preload" as="style" importance="high">
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php foreach ($scripts as $script) : ?>
|
||||
<script data-cfasync="false" src="<?= $script . '?v=' . $coreBuild; ?>"></script>
|
||||
<link href="<?= $script . '?v=' . $coreBuild; ?>" rel="preload" as="script">
|
||||
<script data-cfasync="false" src="<?= $script . '?v=' . $coreBuild; ?>" importance="high"></script>
|
||||
<link href="<?= $script . '?v=' . $coreBuild; ?>" rel="preload" as="script" importance="high">
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?= $this->makeAssets() ?>
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@
|
|||
?>
|
||||
|
||||
<?php foreach ($styles as $style) : ?>
|
||||
<link href="<?= $style . '?v=' . $coreBuild; ?>" rel="stylesheet">
|
||||
<link href="<?= $style . '?v=' . $coreBuild; ?>" rel="preload" as="style">
|
||||
<link href="<?= $style . '?v=' . $coreBuild; ?>" rel="stylesheet" importance="high">
|
||||
<link href="<?= $style . '?v=' . $coreBuild; ?>" rel="preload" as="style" importance="high">
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php foreach ($scripts as $script) : ?>
|
||||
<script data-cfasync="false" src="<?= $script . '?v=' . $coreBuild; ?>"></script>
|
||||
<link href="<?= $script . '?v=' . $coreBuild; ?>" rel="preload" as="script">
|
||||
<script data-cfasync="false" src="<?= $script . '?v=' . $coreBuild; ?>" importance="high"></script>
|
||||
<link href="<?= $script . '?v=' . $coreBuild; ?>" rel="preload" as="script" importance="high">
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?= $this->makeAssets() ?>
|
||||
|
|
|
|||
|
|
@ -35,25 +35,35 @@ class FrameworkNode extends TwigNode
|
|||
$compiler
|
||||
->write("if (\$_minify) {" . PHP_EOL)
|
||||
->indent()
|
||||
->write("echo '<script src=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.combined-min.js\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
->write("echo '<script async src=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.combined-min.js\" importance=\"low\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
->write("echo '<link rel=\"preload\" href=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.combined-min.js\" as=\"script\" importance=\"low\">'.PHP_EOL;" . PHP_EOL)
|
||||
->outdent()
|
||||
->write("}" . PHP_EOL)
|
||||
->write("else {" . PHP_EOL)
|
||||
->indent()
|
||||
->write("echo '<script src=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.js\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
->write("echo '<script src=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.extras.js\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
->write("echo '<script async src=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.js\" importance=\"low\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
->write("echo '<script async src=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.extras.js\" importance=\"low\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
->write("echo '<link rel=\"preload\" href=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.js\" as=\"script\" importance=\"low\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
->write("echo '<link rel=\"preload\" href=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework.extras.js\" as=\"script\" importance=\"low\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
->outdent()
|
||||
->write("}" . PHP_EOL)
|
||||
->write("echo '<link rel=\"stylesheet\" property=\"stylesheet\" href=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/css/framework.extras'.(\$_minify ? '-min' : '').'.css\">'.PHP_EOL;" . PHP_EOL)
|
||||
.'/modules/system/assets/css/framework.extras'.(\$_minify ? '-min' : '').'.css\" importance=\"low\">'.PHP_EOL;" . PHP_EOL)
|
||||
->write("echo '<link rel=\"preload\" href=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/css/framework.extras'.(\$_minify ? '-min' : '').'.css\" as=\"style\" importance=\"low\">'.PHP_EOL;" . PHP_EOL)
|
||||
;
|
||||
}
|
||||
else {
|
||||
$compiler->write("echo '<script src=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework'.(\$_minify ? '-min' : '').'.js\"></script>'.PHP_EOL;" . PHP_EOL)
|
||||
$compiler->write("echo '<script async src=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework'.(\$_minify ? '-min' : '').'.js\" importance=\"low\"></script>
|
||||
<link rel=\"preload\" href=\"'. Request::getBasePath()
|
||||
.'/modules/system/assets/js/framework'.(\$_minify ? '-min' : '').'.js\" as=\"script\" importance=\"low\">'.PHP_EOL;" . PHP_EOL)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue