mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 05:25:16 -05:00
* Revert "Revert "FEATURE: Preload resources via link header (#18475)" (#18511)"
This reverts commit 95a57f7e0c.
* put behind feature flag
* env -> global setting
* declare global setting
* forgot one spot
This commit is contained in:
@@ -196,10 +196,11 @@ class Stylesheet::Manager
|
||||
end.join("\n").html_safe
|
||||
end
|
||||
|
||||
def stylesheet_link_tag(target = :desktop, media = 'all')
|
||||
def stylesheet_link_tag(target = :desktop, media = 'all', preload_callback = nil)
|
||||
stylesheets = stylesheet_details(target, media)
|
||||
stylesheets.map do |stylesheet|
|
||||
href = stylesheet[:new_href]
|
||||
preload_callback.call(href, 'style') if preload_callback
|
||||
theme_id = stylesheet[:theme_id]
|
||||
data_theme_id = theme_id ? "data-theme-id=\"#{theme_id}\"" : ""
|
||||
theme_name = stylesheet[:theme_name]
|
||||
@@ -311,12 +312,13 @@ class Stylesheet::Manager
|
||||
%[<link href="#{href}" rel="preload" as="style"/>].html_safe
|
||||
end
|
||||
|
||||
def color_scheme_stylesheet_link_tag(color_scheme_id = nil, media = 'all')
|
||||
def color_scheme_stylesheet_link_tag(color_scheme_id = nil, media = 'all', preload_callback = nil)
|
||||
stylesheet = color_scheme_stylesheet_details(color_scheme_id, media)
|
||||
|
||||
return '' if !stylesheet
|
||||
|
||||
href = stylesheet[:new_href]
|
||||
preload_callback.call(href, 'style') if preload_callback
|
||||
|
||||
css_class = media == 'all' ? "light-scheme" : "dark-scheme"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user