From 9d971201978e993a9af337d9cd5396a1ea225f00 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 23 Mar 2023 01:29:17 +0800 Subject: [PATCH] perf(assets): reduce HTTP requests to CDN --- _includes/comments/giscus.html | 72 ++++++++++++++++++--------------- _includes/head.html | 2 - _includes/js-selector.html | 38 +++++++++++------ _includes/jsdelivr-combine.html | 6 --- _includes/mermaid.html | 57 +++++++++++++------------- _includes/mode-toggle.html | 65 +++++++++++++++++++---------- _includes/search-loader.html | 49 +++++++++++----------- _includes/toc.html | 3 -- _layouts/default.html | 14 +++---- 9 files changed, 167 insertions(+), 139 deletions(-) diff --git a/_includes/comments/giscus.html b/_includes/comments/giscus.html index 29b848f..ed918a9 100644 --- a/_includes/comments/giscus.html +++ b/_includes/comments/giscus.html @@ -1,44 +1,54 @@ diff --git a/_includes/head.html b/_includes/head.html index 6407c9c..f767edb 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -108,8 +108,6 @@ - - {% unless site.theme_mode %} {% include mode-toggle.html %} {% endunless %} diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 7d2224c..895ccef 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -1,27 +1,35 @@ + + +{% assign urls = site.data.assets[origin].jquery.js + | append: ',' + | append: site.data.assets[origin].bootstrap.js + | append: ',' + | append: site.data.assets[origin].search.js +%} + {% if page.layout == 'post' %} {% if site.google_analytics.pv.proxy_endpoint or site.google_analytics.pv.cache_path %} - + {% assign urls = urls | append: ',' | append: site.data.assets[origin].countup.js %} {% endif %} {% endif %} {% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %} - {% assign _urls = site.data.assets[origin].lazysizes.js %} + {% assign urls = urls | append: ',' | append: site.data.assets[origin].lazysizes.js %} {% unless page.layout == 'home' %} - {% assign _urls = _urls + + {% assign urls = urls | append: ',' | append: site.data.assets[origin]['magnific-popup'].js | append: ',' | append: site.data.assets[origin].clipboard.js %} {% endunless %} - - {% include jsdelivr-combine.html urls=_urls %} {% endif %} {% if page.layout == 'home' @@ -32,7 +40,9 @@ %} {% assign locale = site.lang | split: '-' | first %} - {% assign _urls = site.data.assets[origin].dayjs.js.common + {% assign urls = urls + | append: ',' + | append: site.data.assets[origin].dayjs.js.common | append: ',' | append: site.data.assets[origin].dayjs.js.locale | replace: ':LOCALE', locale @@ -41,10 +51,18 @@ | append: ',' | append: site.data.assets[origin].dayjs.js.localizedFormat %} - - {% include jsdelivr-combine.html urls=_urls %} {% endif %} +{% if page.content contains '