From b77767f76e4901b4c43922be858f79356917edbd Mon Sep 17 00:00:00 2001
From: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date: Mon, 29 Apr 2024 03:43:33 +0800
Subject: [PATCH] refactor: improve js module loading order
---
_includes/js-selector.html | 6 +++++-
_javascript/commons.js | 2 +-
_javascript/home.js | 6 +++---
_javascript/misc.js | 2 +-
_javascript/page.js | 6 +++---
_javascript/post.js | 6 +++---
_layouts/default.html | 5 -----
7 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/_includes/js-selector.html b/_includes/js-selector.html
index 78ef541..3e1eb47 100644
--- a/_includes/js-selector.html
+++ b/_includes/js-selector.html
@@ -65,7 +65,7 @@
{% endcase %}
{% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %}
-
+
{% if page.math %}
@@ -88,6 +88,10 @@
{% endif %}
{% endif %}
+{% if page.mermaid %}
+ {% include mermaid.html %}
+{% endif %}
+
{% if jekyll.environment == 'production' %}
{% if site.pwa.enabled %}
diff --git a/_javascript/commons.js b/_javascript/commons.js
index 05a9765..6a17fb9 100644
--- a/_javascript/commons.js
+++ b/_javascript/commons.js
@@ -1,5 +1,5 @@
import { basic, initSidebar, initTopbar } from './modules/layouts';
-basic();
initSidebar();
initTopbar();
+basic();
diff --git a/_javascript/home.js b/_javascript/home.js
index 02948c9..ef22cb9 100644
--- a/_javascript/home.js
+++ b/_javascript/home.js
@@ -1,8 +1,8 @@
import { basic, initSidebar, initTopbar } from './modules/layouts';
import { initLocaleDatetime, loadImg } from './modules/plugins';
-basic();
+loadImg();
+initLocaleDatetime();
initSidebar();
initTopbar();
-initLocaleDatetime();
-loadImg();
+basic();
diff --git a/_javascript/misc.js b/_javascript/misc.js
index c7a19d6..52b4043 100644
--- a/_javascript/misc.js
+++ b/_javascript/misc.js
@@ -1,7 +1,7 @@
import { basic, initSidebar, initTopbar } from './modules/layouts';
import { initLocaleDatetime } from './modules/plugins';
-basic();
initSidebar();
initTopbar();
initLocaleDatetime();
+basic();
diff --git a/_javascript/page.js b/_javascript/page.js
index f13bd2f..76e8ce9 100644
--- a/_javascript/page.js
+++ b/_javascript/page.js
@@ -1,9 +1,9 @@
import { basic, initSidebar, initTopbar } from './modules/layouts';
import { loadImg, imgPopup, initClipboard } from './modules/plugins';
-basic();
-initSidebar();
-initTopbar();
loadImg();
imgPopup();
+initSidebar();
+initTopbar();
initClipboard();
+basic();
diff --git a/_javascript/post.js b/_javascript/post.js
index 86ea32b..9340f05 100644
--- a/_javascript/post.js
+++ b/_javascript/post.js
@@ -7,11 +7,11 @@ import {
toc
} from './modules/plugins';
-initSidebar();
-initTopbar();
loadImg();
+toc();
imgPopup();
+initSidebar();
initLocaleDatetime();
initClipboard();
-toc();
+initTopbar();
basic();
diff --git a/_layouts/default.html b/_layouts/default.html
index 6e865b9..ea438fe 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -75,13 +75,8 @@ layout: compress
{% endif %}
-
{% include js-selector.html lang=lang %}
- {% if page.mermaid %}
- {% include mermaid.html %}
- {% endif %}
-
{% include_cached search-loader.html lang=lang %}