Skip to content

Commit

Permalink
Fixed a Resource class bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Dec 2, 2017
1 parent c15cb31 commit 1effd9d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions system/classes/Resource.php
Expand Up @@ -39,6 +39,7 @@ class Resource
const DEFAULT_CACHE_LIFESPAN = 604800; // 1 week

const JS_TAG_TEMPLATE = '<script type="text/javascript" src="%s"></script>';
const EXTERNAL_JS_TAG_TEMPLATE = '<script type="text/javascript" src="%s" async defer></script>';

// Default theme
const DEFAULT_THEME = 'denim';
Expand Down Expand Up @@ -879,7 +880,7 @@ private function makeFileServerTag(array $files, $isCss = true)

if ($success && !$this->debug) {
$url = $this->config['site_url'] . '/r.php?k=' . $key;
$retval .= sprintf('<script type="text/javascript" src="%s"></script>', $url);
$retval .= sprintf(self::JS_TAG_TEMPLATE, $url);
} else {
// Somehow failed to save data into cache or debug mode is on
$retval .= PHP_EOL;
Expand Down Expand Up @@ -1105,7 +1106,7 @@ public function getHeader()
usort($this->externalJsFiles['header'], array('\\Geeklog\\Resource', 'comparePriority'));

foreach ($this->externalJsFiles['header'] as $jsFile) {
$retval .= sprintf(self::JS_TAG_TEMPLATE, $jsFile['file']) . PHP_EOL;
$retval .= sprintf(self::EXTERNAL_JS_TAG_TEMPLATE, $jsFile['file']) . PHP_EOL;
}
}

Expand Down Expand Up @@ -1157,7 +1158,7 @@ public function getHeader()
if ($this->debug) {
$retval .= '<script type="text/javascript">'
. implode(PHP_EOL, $this->jsBlocks['header'])
. '</<script>' . PHP_EOL;
. '</script>' . PHP_EOL;
} else {
$code = implode(PHP_EOL, $this->jsBlocks['header']);
$code = JSMin::minify($code);
Expand Down Expand Up @@ -1185,7 +1186,7 @@ public function getFooter()
usort($this->externalJsFiles['footer'], array('\\Geeklog\\Resource', 'comparePriority'));

foreach ($this->externalJsFiles['footer'] as $jsFile) {
$retval .= sprintf('<script src="%s" async defer></script>', $jsFile['file']) . PHP_EOL;
$retval .= sprintf(self::EXTERNAL_JS_TAG_TEMPLATE, $jsFile['file']) . PHP_EOL;
}
}

Expand Down

0 comments on commit 1effd9d

Please sign in to comment.