Skip to content

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.rb
index 2f09d35e9f7..5af27c985bd 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -151,16 +151,10 @@ module ApplicationHelper
nonce_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>
+ HTML
end
def add_resource_preload_list(resource_url, type)
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 013e7143b41..6526ba884d4 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -5,7 +5,6 @@ RSpec.describe ApplicationHelper do
describe "preload_script" do
def 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>
HTML
end