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 /core/templates | |
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 'core/templates')
-rw-r--r-- | core/templates/layout.base.php | 9 | ||||
-rw-r--r-- | core/templates/layout.guest.php | 9 | ||||
-rw-r--r-- | core/templates/layout.user.php | 9 |
3 files changed, 3 insertions, 24 deletions
diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index e2e61e67e2c..7eb1cf5ffa4 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -12,20 +12,13 @@ <link rel="icon" href="<?php print_unescaped(image_path('', 'favicon.ico')); /* IE11+ supports png */ ?>"> <link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path('', 'favicon-touch.png')); ?>"> <link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path('', 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>"> - <?php if (isset($_['inline_ocjs'])): ?> - <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> - <?php print_unescaped($_['inline_ocjs']); ?> - </script> - <?php endif; ?> <?php foreach ($_['cssfiles'] as $cssfile): ?> <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>"> <?php endforeach; ?> <?php foreach($_['printcssfiles'] as $cssfile): ?> <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> <?php endforeach; ?> - <?php foreach ($_['jsfiles'] as $jsfile): ?> - <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> - <?php endforeach; ?> + <?php emit_script_loading_tags($_); ?> <?php print_unescaped($_['headers']); ?> </head> <body id="body-public"> diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 2c2373d53aa..dc56edb0061 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -13,20 +13,13 @@ <link rel="icon" href="<?php print_unescaped(image_path('', 'favicon.ico')); /* IE11+ supports png */ ?>"> <link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path('', 'favicon-touch.png')); ?>"> <link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path('', 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>"> - <?php if (isset($_['inline_ocjs'])): ?> - <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> - <?php print_unescaped($_['inline_ocjs']); ?> - </script> - <?php endif; ?> <?php foreach($_['cssfiles'] as $cssfile): ?> <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>"> <?php endforeach; ?> <?php foreach($_['printcssfiles'] as $cssfile): ?> <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> <?php endforeach; ?> - <?php foreach($_['jsfiles'] as $jsfile): ?> - <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> - <?php endforeach; ?> + <?php emit_script_loading_tags($_); ?> <?php print_unescaped($_['headers']); ?> </head> <body id="<?php p($_['bodyid']);?>"> diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 978534b869c..aad9875f375 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -21,20 +21,13 @@ <link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path($_['appid'], 'favicon-touch.png')); ?>"> <link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path($_['appid'], 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>"> <link rel="manifest" href="<?php print_unescaped(image_path($_['appid'], 'manifest.json')); ?>"> - <?php if (isset($_['inline_ocjs'])): ?> - <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> - <?php print_unescaped($_['inline_ocjs']); ?> - </script> - <?php endif; ?> <?php foreach($_['cssfiles'] as $cssfile): ?> <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>"> <?php endforeach; ?> <?php foreach($_['printcssfiles'] as $cssfile): ?> <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> <?php endforeach; ?> - <?php foreach($_['jsfiles'] as $jsfile): ?> - <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> - <?php endforeach; ?> + <?php emit_script_loading_tags($_); ?> <?php print_unescaped($_['headers']); ?> </head> <body id="<?php p($_['bodyid']);?>"> |