From a39b996990dcb9f9ffd27d903d3d614c47c09b5f Mon Sep 17 00:00:00 2001 From: Michael Letzgus Date: Wed, 8 Mar 2017 09:43:51 +0100 Subject: [PATCH] Make page loading faster: 1. Remove type attribute from inline_js 2. Add defer attribute to external script 3. Move inline_script down Date: Wed Mar 8 09:43:51 2017 +0100 Committer: Michael Letzgus Signed-off-by: Michael Letzgus --- core/templates/layout.base.php | 10 +++++----- core/templates/layout.guest.php | 10 +++++----- core/templates/layout.user.php | 10 +++++----- lib/private/legacy/template.php | 3 +++ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index d6d70f31362a2..fba06eb83ca5a 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -18,15 +18,15 @@ + + + + - - - - - diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 1692e4268d474..eefd1e711cb56 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -19,15 +19,15 @@ + + + + - - - - - diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 3cfb88bf423d9..484fa6d3cc940 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -26,15 +26,15 @@ + + + + - - - - - diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php index 8535e0188793e..4384df7f6adcf 100644 --- a/lib/private/legacy/template.php +++ b/lib/private/legacy/template.php @@ -223,6 +223,9 @@ public function fetchPage($additionalParams = null) { $headers = ''; foreach(OC_Util::$headers as $header) { $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); + if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) { + $headers .= ' defer'; + } foreach($header['attributes'] as $name=>$value) { $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; }