From d27e7e8ee396facadb9dd92861ba800274492569 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 9 Jul 2024 21:38:41 +0200 Subject: [PATCH] make scriptTag parameter a string for flexibility and clarity --- lib/View.php | 6 +++--- tpl/bootstrap.php | 24 ++++++++++++------------ tpl/bootstrap5.php | 26 +++++++++++++------------- tpl/page.php | 4 ++-- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/View.php b/lib/View.php index 8c21f341..5e253580 100644 --- a/lib/View.php +++ b/lib/View.php @@ -63,15 +63,15 @@ class View * * @access private * @param string $file - * @param bool $async should it execute ASAP or only after HTML got parsed + * @param string $attributes additional attributes to add into the script tag */ - private function _scriptTag($file, $async = true) + private function _scriptTag($file, $attributes = '') { $sri = array_key_exists($file, $this->_variables['SRI']) ? ' integrity="' . $this->_variables['SRI'][$file] . '"' : ''; $suffix = preg_match('#\d.js$#', $file) == 0 ? '?' . rawurlencode($this->_variables['VERSION']) : ''; - echo '', PHP_EOL; } diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 2ae57582..9f266615 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -42,38 +42,38 @@ if ($SYNTAXHIGHLIGHTING) : endif; ?> - _scriptTag('js/jquery-3.7.1.js', false); ?> + _scriptTag('js/jquery-3.7.1.js', 'async'); ?> - _scriptTag('js/kjua-0.9.0.js'); ?> + _scriptTag('js/kjua-0.9.0.js', 'async'); ?> - _scriptTag('js/base64-1.7.js'); ?> + _scriptTag('js/base64-1.7.js', 'async'); ?> - _scriptTag('js/zlib-1.3.1.js'); ?> - _scriptTag('js/base-x-4.0.0.js'); ?> - _scriptTag('js/rawinflate-0.3.js'); ?> - _scriptTag('js/bootstrap-3.4.1.js', false); ?> + _scriptTag('js/zlib-1.3.1.js', 'async'); ?> + _scriptTag('js/base-x-4.0.0.js', 'async'); ?> + _scriptTag('js/rawinflate-0.3.js', 'async'); ?> + _scriptTag('js/bootstrap-3.4.1.js', 'defer'); ?> - _scriptTag('js/prettify.js'); ?> + _scriptTag('js/prettify.js', 'async'); ?> - _scriptTag('js/showdown-2.1.0.js'); ?> + _scriptTag('js/showdown-2.1.0.js', 'async'); ?> - _scriptTag('js/purify-3.1.3.js'); ?> - _scriptTag('js/legacy.js'); ?> - _scriptTag('js/privatebin.js', false); ?> + _scriptTag('js/purify-3.1.3.js', 'async'); ?> + _scriptTag('js/legacy.js', 'async'); ?> + _scriptTag('js/privatebin.js', 'defer'); ?> diff --git a/tpl/bootstrap5.php b/tpl/bootstrap5.php index 3700bd98..64bb9677 100644 --- a/tpl/bootstrap5.php +++ b/tpl/bootstrap5.php @@ -25,39 +25,39 @@ if ($SYNTAXHIGHLIGHTING) : endif; ?> - _scriptTag('js/jquery-3.7.1.js', false); ?> + _scriptTag('js/jquery-3.7.1.js', 'defer'); ?> - _scriptTag('js/kjua-0.9.0.js'); ?> + _scriptTag('js/kjua-0.9.0.js', 'async'); ?> - _scriptTag('js/base64-1.7.js'); ?> + _scriptTag('js/base64-1.7.js', 'async'); ?> - _scriptTag('js/zlib-1.3.1.js'); ?> - _scriptTag('js/base-x-4.0.0.js'); ?> - _scriptTag('js/rawinflate-0.3.js'); ?> - _scriptTag('js/bootstrap-5.3.3.js'); ?> - _scriptTag('js/dark-mode-switch.js'); ?> + _scriptTag('js/zlib-1.3.1.js', 'async'); ?> + _scriptTag('js/base-x-4.0.0.js', 'async'); ?> + _scriptTag('js/rawinflate-0.3.js', 'async'); ?> + _scriptTag('js/bootstrap-5.3.3.js', 'async'); ?> + _scriptTag('js/dark-mode-switch.js', 'async'); ?> - _scriptTag('js/prettify.js'); ?> + _scriptTag('js/prettify.js', 'async'); ?> - _scriptTag('js/showdown-2.1.0.js'); ?> + _scriptTag('js/showdown-2.1.0.js', 'async'); ?> - _scriptTag('js/purify-3.1.3.js'); ?> - _scriptTag('js/legacy.js'); ?> - _scriptTag('js/privatebin.js', false); ?> + _scriptTag('js/purify-3.1.3.js', 'async'); ?> + _scriptTag('js/legacy.js', 'async'); ?> + _scriptTag('js/privatebin.js', 'defer'); ?> diff --git a/tpl/page.php b/tpl/page.php index 8a83c9cd..18e3b9a7 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -21,7 +21,7 @@ if ($SYNTAXHIGHLIGHTING): endif; endif; ?> - _scriptTag('js/jquery-3.7.1.js', false); ?> + _scriptTag('js/jquery-3.7.1.js', 'defer'); ?> @@ -51,7 +51,7 @@ endif; ?> _scriptTag('js/purify-3.1.3.js'); ?> _scriptTag('js/legacy.js'); ?> - _scriptTag('js/privatebin.js', false); ?> + _scriptTag('js/privatebin.js', 'defer'); ?>