A platform for community discussion. Free, open, simple.
PERF: Remove unnecessary `<link rel="preload">` (#26219)
Alan Guo Xiang Tane2da72b76c7f
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex 2f09d35e9f7..5af27c985bd 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -151,16 +151,10 @@ module ApplicationHelpernonce_attribute = "nonce=\"#{csp_nonce_placeholder}\""add_resource_preload_list(url, "script")- if GlobalSetting.preload_link_header- <<~HTML.html_safe- <script defer src="#{url}" #{entrypoint_attribute} #{nonce_attribute}></script>- HTML- else- <<~HTML.html_safe- <link rel="preload" href="#{url}" as="script" #{entrypoint_attribute} #{nonce_attribute}>- <script defer src="#{url}" #{entrypoint_attribute} #{nonce_attribute}></script>- HTML- end++ <<~HTML.html_safe+ <script defer src="#{url}" #{entrypoint_attribute} #{nonce_attribute}></script>+ HTMLenddef add_resource_preload_list(resource_url, type)diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rbindex 013e7143b41..6526ba884d4 100644--- a/spec/helpers/application_helper_spec.rb+++ b/spec/helpers/application_helper_spec.rb@@ -5,7 +5,6 @@ RSpec.describe ApplicationHelper dodescribe "preload_script" dodef script_tag(url, entrypoint, nonce)<<~HTML- <link rel="preload" href="#{url}" as="script" data-discourse-entrypoint="#{entrypoint}" nonce="#{nonce}"><script defer src="#{url}" data-discourse-entrypoint="#{entrypoint}" nonce="#{nonce}"></script>HTMLend