From fb9f13d4c13d2ea3ba70095f36e73c8915fce47f 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 by deferred script loading: * Create generalized function for emmitting - - - - + diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 2c2373d53a..dc56edb006 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -13,20 +13,13 @@ - - - - - - + diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 978534b869..aad9875f37 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -21,20 +21,13 @@ - - - - - - + diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php index b4c6932743..4f7c11d0b6 100644 --- a/lib/private/legacy/template.php +++ b/lib/private/legacy/template.php @@ -12,6 +12,7 @@ * @author Joas Schilling * @author Jörn Friedrich Dreyer * @author Lukas Reschke + * @author Michael Letzgus * @author Morris Jobke * @author Raghu Nayyar * @author Robin Appelman @@ -208,6 +209,9 @@ class OC_Template extends \OC\Template\Base { $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).'"'; } diff --git a/lib/private/legacy/template/functions.php b/lib/private/legacy/template/functions.php index 7814918b81..06eb512b54 100644 --- a/lib/private/legacy/template/functions.php +++ b/lib/private/legacy/template/functions.php @@ -7,6 +7,7 @@ * @author Joas Schilling * @author Jörn Friedrich Dreyer * @author Lukas Reschke + * @author Michael Letzgus * @author Morris Jobke * @author Robin McCorkell * @author Roeland Jago Douma @@ -37,6 +38,42 @@ function p($string) { print(\OCP\Util::sanitizeHTML($string)); } +/** + * Prints a '; + print_unescaped($s."\n"); +} + +/** + * Print all