diff options
author | Michael Letzgus <www@chronos.michael-letzgus.de> | 2017-03-08 09:43:51 +0100 |
---|---|---|
committer | Michael Letzgus <www@chronos.michael-letzgus.de> | 2017-05-20 13:44:04 +0200 |
commit | fb9f13d4c13d2ea3ba70095f36e73c8915fce47f (patch) | |
tree | f64c25ff3cd53b1f9fbb8bc2a91c43699e62a231 /lib/private/legacy/template.php | |
parent | 6e3a914f4affde68c5cafa8fc7703efa3c3deaa6 (diff) | |
download | nextcloud-server-fb9f13d4c13d2ea3ba70095f36e73c8915fce47f.tar.gz nextcloud-server-fb9f13d4c13d2ea3ba70095f36e73c8915fce47f.zip |
Make page loading faster by deferred script loading:
* Create generalized function for emmitting <script defer src=""> tags to templates
* Remove type attribute from inline_js
* Add defer attribute to external <script> tags
Signed-off-by: Michael Letzgus <michaelletzgus@users.noreply.github.com>
Diffstat (limited to 'lib/private/legacy/template.php')
-rw-r--r-- | lib/private/legacy/template.php | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php index b4c69327438..4f7c11d0b64 100644 --- a/lib/private/legacy/template.php +++ b/lib/private/legacy/template.php @@ -12,6 +12,7 @@ * @author Joas Schilling <coding@schilljs.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@statuscode.ch> + * @author Michael Letzgus <develope@michael-letzgus.de> * @author Morris Jobke <hey@morrisjobke.de> * @author Raghu Nayyar <hey@raghunayyar.com> * @author Robin Appelman <robin@icewind.nl> @@ -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).'"'; } |