From 2698778c56ee7dffa22cca22ab7a2396dae48895 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Mon, 29 Apr 2024 07:49:41 +0800 Subject: [PATCH] refactor!: optimize the resource hints --- _data/origin/cors.yml | 15 ++++++++------- _includes/head.html | 35 +++++++++++++---------------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/_data/origin/cors.yml b/_data/origin/cors.yml index a10d31cc274..bec09a57a6f 100644 --- a/_data/origin/cors.yml +++ b/_data/origin/cors.yml @@ -1,17 +1,18 @@ -# CDNs +# Resource Hints -cdns: +resource_hints: # Google Fonts - url: https://fonts.googleapis.com + rel: [preconnect, dns-prefetch] + # Google Fonts download - url: https://fonts.gstatic.com - args: crossorigin - - url: https://fonts.googleapis.com + rel: [preconnect, dns-prefetch] + attributes: [crossorigin] # jsDelivr CDN - url: https://cdn.jsdelivr.net - # polyfill.io for math (cdnjs.cloudflare.com/polyfill) - - url: https://cdnjs.cloudflare.com + rel: [preconnect, dns-prefetch] -# fonts +# Fonts webfonts: https://fonts.googleapis.com/css2?family=Lato:wght@300;400&family=Source+Sans+Pro:wght@400;600;700;900&display=swap diff --git a/_includes/head.html b/_includes/head.html index f3434cf5f8d..a9adcd79138 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -59,34 +59,25 @@ {% include_cached favicons.html %} - {% if site.resources.ignore_env != jekyll.environment and site.resources.self_hosted %} - - - {% else %} - {% for cdn in site.data.origin[type].cdns %} - - + + {% unless site.resources.self_hosted %} + {% for hint in site.data.origin[type].resource_hints %} + {% for rel in hint.rel %} + + {% endfor %} {% endfor %} + {% endunless %} - - {% endif %} - - - {% if jekyll.environment == 'production' and site.analytics.google.id != empty and site.analytics.google.id %} - - - - - - {% endif %} + + - - + + - + - + {% if site.toc and page.toc %}