Add preload tag for main.css (#577)

* Add preload tag for main.css

Improve performance. In addition, CloudFlare has supported early hints with this tag.
See https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload
See also https://blog.cloudflare.com/early-hints-on-cloudflare-pages/

* Associate with the preconnect option

Co-authored-by: Mimi <stevenjoezhang@gmail.com>
This commit is contained in:
Jinzhe Zeng 2022-10-25 01:25:12 -04:00 committed by GitHub
parent c85cbe7c0e
commit 110cb84626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -336,7 +336,7 @@ calendar:
# See: https://theme-next.js.org/docs/theme-settings/miscellaneous
# ---------------------------------------------------------------
# Preconnect CDN for fonts and plugins.
# Preload styles and preconnect CDN for fonts and plugins.
# For more information: https://www.w3.org/TR/resource-hints/#preconnect
preconnect: false

View File

@ -10,6 +10,9 @@
{{- meta_generator() }}
{%- endif %}
{%- if config.preconnect %}
<link rel="preload" href="{{ url_for(theme.css) }}/main.css" as="style">
{%- endif %}
{{ next_pre() }}
{%- if theme.favicon.apple_touch_icon %}