DEV: Defer loading core/plugin/theme JS files (#17063)

This is pre-request work to introduce a splash screen while site assets load.

The only change this commit introduces is that it ensures we add the defer attribute to core/plugin/theme .JS files. This will allow us to insert markup before the browser starts evaluating those scripts later on. It has no visual or functional impact on core.

This will not have any impact on how themes and plugins work. The only exception is themes loading external scripts in the </head> theme field directly via script tags. Everything will work the same but those would need to add the defer attribute if they want to keep the benefits introduced in this PR.
This commit is contained in:
Joe
2022-06-20 09:47:37 +08:00
committed by GitHub
parent 410ab5d587
commit 804b8fd9f9
11 changed files with 30 additions and 24 deletions

View File

@@ -153,7 +153,7 @@ module ApplicationHelper
def preload_script_url(url)
<<~HTML.html_safe
<link rel="preload" href="#{url}" as="script">
<script src="#{url}"></script>
<script defer src="#{url}"></script>
HTML
end