Skip to content

A platform for community discussion. Free, open, simple.

PERF: Remove unnecessary <link rel="preload"> for theme javascript (#26220)

Alan Guo Xiang Tan239b70342fb7
diff --git a/app/models/theme.rb b/app/models/theme.rb
index 5a8b66fa3d4..f4b66c16852 100644
--- a/app/models/theme.rb
+++ b/app/models/theme.rb
@@ -6,7 +6,7 @@ require "json_schemer"
class Theme < ActiveRecord::Base
include GlobalPath
- BASE_COMPILER_VERSION = 80
+ BASE_COMPILER_VERSION = 81
class SettingsMigrationError < StandardError
end
@@ -471,7 +471,6 @@ class Theme < ActiveRecord::Base
.compact
caches.map { |c| <<~HTML.html_safe }.join("\n")
- <link rel="preload" href="#{c.url}" as="script" nonce="#{ThemeField::CSP_NONCE_PLACEHOLDER}">
<script defer src="#{c.url}" data-theme-id="#{c.theme_id}" nonce="#{ThemeField::CSP_NONCE_PLACEHOLDER}"></script>
HTML
end
diff --git a/app/models/theme_field.rb b/app/models/theme_field.rb
index 38dc09d28f6..5387c9a79da 100644
--- a/app/models/theme_field.rb
+++ b/app/models/theme_field.rb
@@ -191,7 +191,6 @@ class ThemeField < ActiveRecord::Base
javascript_cache.save!
doc.add_child(<<~HTML.html_safe) if javascript_cache.content.present?
- <link rel="preload" href="#{javascript_cache.url}" as="script" nonce="#{CSP_NONCE_PLACEHOLDER}">
<script defer src='#{javascript_cache.url}' data-theme-id='#{theme_id}' nonce="#{CSP_NONCE_PLACEHOLDER}"></script>
HTML
[doc.to_s, errors&.join("\n")]
@@ -300,7 +299,6 @@ class ThemeField < ActiveRecord::Base
javascript_cache.save!
doc = ""
doc = <<~HTML.html_safe if javascript_cache.content.present?
- <link rel="preload" href="#{javascript_cache.url}" as="script" nonce="#{ThemeField::CSP_NONCE_PLACEHOLDER}">
<script defer src="#{javascript_cache.url}" data-theme-id="#{theme_id}" nonce="#{ThemeField::CSP_NONCE_PLACEHOLDER}"></script>
HTML
[doc, errors&.join("\n")]