mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 10:54:50 +08:00
FEATURE: try adding some preload hints for chrome
This commit is contained in:
@ -45,17 +45,17 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def script(*args)
|
def preload_script(script)
|
||||||
|
path = asset_path("#{script}.js")
|
||||||
|
|
||||||
if GlobalSetting.cdn_url &&
|
if GlobalSetting.cdn_url &&
|
||||||
GlobalSetting.cdn_url.start_with?("https") &&
|
GlobalSetting.cdn_url.start_with?("https") &&
|
||||||
ENV["COMPRESS_BROTLI"] == "1" &&
|
ENV["COMPRESS_BROTLI"] == "1" &&
|
||||||
request.env["HTTP_ACCEPT_ENCODING"] =~ /br/
|
request.env["HTTP_ACCEPT_ENCODING"] =~ /br/
|
||||||
tags = javascript_include_tag(*args)
|
path.gsub!("#{GlobalSetting.cdn_url}/assets/", "#{GlobalSetting.cdn_url}/brotli_asset/")
|
||||||
tags.gsub!("#{GlobalSetting.cdn_url}/assets/", "#{GlobalSetting.cdn_url}/brotli_asset/")
|
|
||||||
tags.html_safe
|
|
||||||
else
|
|
||||||
javascript_include_tag(*args)
|
|
||||||
end
|
end
|
||||||
|
"<link rel='preload' href='#{path}' as='script'/>
|
||||||
|
<script src='#{path}'></script>".html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def discourse_csrf_tags
|
def discourse_csrf_tags
|
||||||
|
@ -65,4 +65,4 @@
|
|||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<%= script 'browser-update' %>
|
<%= preload_script 'browser-update' %>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
<% font_domain = "#{request.protocol}#{request.host_with_port}&2" %>
|
<% font_domain = "#{request.protocol}#{request.host_with_port}&2" %>
|
||||||
|
|
||||||
|
<link rel="preload" href="<%=asset_path "fontawesome-webfont.woff2"%>" as="font" type="font/woff2" crossorigin />
|
||||||
<style>
|
<style>
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'FontAwesome';
|
font-family: 'FontAwesome';
|
||||||
|
@ -23,22 +23,22 @@
|
|||||||
window.EmberENV['FORCE_JQUERY'] = true;
|
window.EmberENV['FORCE_JQUERY'] = true;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<%= script "locales/#{I18n.locale}" %>
|
<%= preload_script "locales/#{I18n.locale}" %>
|
||||||
<%= script "ember_jquery" %>
|
<%= preload_script "ember_jquery" %>
|
||||||
<%= script "preload-store" %>
|
<%= preload_script "preload-store" %>
|
||||||
<%= script "vendor" %>
|
<%= preload_script "vendor" %>
|
||||||
<%= script "pretty-text-bundle" %>
|
<%= preload_script "pretty-text-bundle" %>
|
||||||
<%= script "application" %>
|
<%= preload_script "application" %>
|
||||||
<%- if allow_plugins? %>
|
<%- if allow_plugins? %>
|
||||||
<%= script "plugin" %>
|
<%= preload_script "plugin" %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
<%- if allow_third_party_plugins? %>
|
<%- if allow_third_party_plugins? %>
|
||||||
<%= script "plugin-third-party" %>
|
<%= preload_script "plugin-third-party" %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
<%- if staff? %>
|
<%- if staff? %>
|
||||||
<script src="<%= Discourse.base_uri %>/extra-locales/admin"></script>
|
<script src="<%= Discourse.base_uri %>/extra-locales/admin"></script>
|
||||||
<%= script "admin" %>
|
<%= preload_script "admin" %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
<%- unless customization_disabled? %>
|
<%- unless customization_disabled? %>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<%- unless customization_disabled? %>
|
<%- unless customization_disabled? %>
|
||||||
<%= discourse_stylesheet_link_tag :embedded_theme %>
|
<%= discourse_stylesheet_link_tag :embedded_theme %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
<%= javascript_include_tag 'break_string' %>
|
<%= preload_script 'break_string' %>
|
||||||
|
|
||||||
<%- if @topic_view && @topic_view.page_title.present? %>
|
<%- if @topic_view && @topic_view.page_title.present? %>
|
||||||
<title><%= @topic_view.page_title %> - <%= SiteSetting.title %></title>
|
<title><%= @topic_view.page_title %> - <%= SiteSetting.title %></title>
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<%= discourse_stylesheet_link_tag 'wizard', theme_key: nil %>
|
<%= discourse_stylesheet_link_tag 'wizard', theme_key: nil %>
|
||||||
<%= render partial: "common/special_font_face" %>
|
<%= render partial: "common/special_font_face" %>
|
||||||
<%= script 'ember_jquery' %>
|
<%= preload_script 'ember_jquery' %>
|
||||||
<%= script 'wizard-vendor' %>
|
<%= preload_script 'wizard-vendor' %>
|
||||||
<%= render partial: "layouts/head" %>
|
<%= render partial: "layouts/head" %>
|
||||||
<title><%= t 'wizard.title' %></title>
|
<title><%= t 'wizard.title' %></title>
|
||||||
</head>
|
</head>
|
||||||
|
@ -36,7 +36,7 @@ class Stylesheet::Manager
|
|||||||
builder = self.new(target, theme_key)
|
builder = self.new(target, theme_key)
|
||||||
builder.compile unless File.exists?(builder.stylesheet_fullpath)
|
builder.compile unless File.exists?(builder.stylesheet_fullpath)
|
||||||
builder.ensure_digestless_file
|
builder.ensure_digestless_file
|
||||||
tag = %[<link href="#{builder.stylesheet_path}" media="#{media}" rel="stylesheet" data-target="#{target}"/>]
|
tag = %[<link href="#{builder.stylesheet_path}" media="#{media}" rel="stylesheet" data-target="#{target}" rel="preload"/>]
|
||||||
cache[cache_key] = tag
|
cache[cache_key] = tag
|
||||||
|
|
||||||
tag.dup.html_safe
|
tag.dup.html_safe
|
||||||
|
Reference in New Issue
Block a user