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 %}