PERF: Move `preload` hints to the `<head>` (#15008)

We have two JS assets which are included in the `<body>` of responses. We were including the `<link rel='preload'` hint alongside the script tag in the body. Instead, we can move the preload hint to the `<head>` so that the browser discovers it earlier, and can start preloading the assets while the body is loading.
This commit is contained in:
David Taylor 2021-11-18 18:02:16 +00:00 committed by GitHub
parent 510219a0da
commit ed2c3ebd71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -21,6 +21,8 @@
<%= build_plugin_html 'server:before-script-load' %>
<link rel="preload" href="<%= script_asset_path "start-discourse" %>" as="script">
<link rel="preload" href="<%= script_asset_path "browser-update" %>" as="script">
<%= preload_script 'browser-detect' %>
<%= preload_script "locales/#{I18n.locale}" %>
@ -113,11 +115,12 @@
<% end %>
<div class="hidden" id="data-preloaded" data-preloaded="<%= preloaded_json %>"></div>
<%= preload_script "start-discourse" %>
<script src="<%= script_asset_path "start-discourse" %>"></script>
<%= yield :data %>
<%= preload_script 'browser-update' %>
<script src="<%= script_asset_path "browser-update" %>"></script>
<%- unless customization_disabled? %>
<%= theme_lookup("body_tag") %>