-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Deferred script loading v2 #3696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,15 +18,15 @@ | |
| <?php foreach($_['printcssfiles'] as $cssfile): ?> | ||
| <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> | ||
| <?php endforeach; ?> | ||
| <?php foreach ($_['jsfiles'] as $jsfile): ?> | ||
| <script defer nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> | ||
| <?php endforeach; ?> | ||
| <?php print_unescaped($_['headers']); ?> | ||
| <?php if (isset($_['inline_ocjs'])): ?> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this change required?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know, for me both version work faster. In short: The change is possibly not required for defeating the performance problem... |
||
| <?php print_unescaped($_['inline_ocjs']); ?> | ||
| </script> | ||
| <?php endif; ?> | ||
| <?php foreach ($_['jsfiles'] as $jsfile): ?> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> | ||
| <?php endforeach; ?> | ||
| <?php print_unescaped($_['headers']); ?> | ||
| </head> | ||
| <body id="body-public"> | ||
| <?php include('layout.noscript.warning.php'); ?> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,15 +19,15 @@ | |
| <?php foreach($_['printcssfiles'] as $cssfile): ?> | ||
| <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> | ||
| <?php endforeach; ?> | ||
| <?php foreach($_['jsfiles'] as $jsfile): ?> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same problem/question here |
||
| <script defer nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> | ||
| <?php endforeach; ?> | ||
| <?php print_unescaped($_['headers']); ?> | ||
| <?php if (isset($_['inline_ocjs'])): ?> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>"> | ||
| <?php print_unescaped($_['inline_ocjs']); ?> | ||
| </script> | ||
| <?php endif; ?> | ||
| <?php foreach($_['jsfiles'] as $jsfile): ?> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> | ||
| <?php endforeach; ?> | ||
| <?php print_unescaped($_['headers']); ?> | ||
| </head> | ||
| <body id="<?php p($_['bodyid']);?>"> | ||
| <?php include('layout.noscript.warning.php'); ?> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,15 +26,15 @@ | |
| <?php foreach($_['printcssfiles'] as $cssfile): ?> | ||
| <link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> | ||
| <?php endforeach; ?> | ||
| <?php foreach($_['jsfiles'] as $jsfile): ?> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| <script defer nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> | ||
| <?php endforeach; ?> | ||
| <?php print_unescaped($_['headers']); ?> | ||
| <?php if (isset($_['inline_ocjs'])): ?> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>"> | ||
| <?php print_unescaped($_['inline_ocjs']); ?> | ||
| </script> | ||
| <?php endif; ?> | ||
| <?php foreach($_['jsfiles'] as $jsfile): ?> | ||
| <script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script> | ||
| <?php endforeach; ?> | ||
| <?php print_unescaped($_['headers']); ?> | ||
| </head> | ||
| <body id="<?php p($_['bodyid']);?>"> | ||
| <?php include('layout.noscript.warning.php'); ?> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really have to move those lines up? This could potentially change/break the loading order with the scripts below (inline_ocjs)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, it changed the order. inline_ocjs will be executed first (while parsing), the deferred scripts after parsing but before the
DOMContentLoadedevent comes up.The standard states: "The defer attribute is only for external scripts (should only be used if the src attribute is present)."
I have found no code in the inline_ocjs which depends on other.
If the old order of execution (first inline, then extern) is desired the inline script code must become external. So why do we have internal code here at all? I think all these variables could be loaded form extern as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChristophWurst
In fact this does NOT change the order of execution when using
deferfor the external script, it only allows Firefox to download css and js in parallel.With the inline_js block placed between css and js downloading of css and js happens synchronously. This seems to be a "feature" of at least Firefox...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for the explanation :-)