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